Hi, The object file is supposed to be automatically linked into your application when you link to the static library target. That's handled by the qt6_add_resources call that qt6_add_shaders call, and it assumes you use target names for linking, and not file paths. If it doesn't, i suspect you're doing something special in your project. Are you perhaps adding the shadert to a static library in one project, and then trying to reuse the static library in a different project?
> On 13. Sep 2023, at 00:10, Ranen Ghosh via Development > <development@qt-project.org> wrote: > > Hi, I've found that there's a cpp file, and then an object file, generated > with the name qrc_<RESOURCE_NAME>. And the object file includes the symbol > qInitResources_<RESOURCE_NAME> > (See https://doc.qt.io/qt-6/qt-add-resources.html for where <RESOURCE_NAME> > comes from, as qt6_add_shaders calls qt6_add_resources) > > So the only remaining issue is that just calling qt6_add_shaders in the cmake > and Q_INIT_RESOURCE(<RESOURCE_NAME>) in cpp results in > > Undefined symbol: qInitResources_<RESOURCE_NAME>() > > So there is still something remaining to do in the cmake that is not handled > by the call to qt6_add_shaders. > > > Ranen Ghosh > Software Developer | EFB | tel. +1519 747 1170 > NAVBLUE | 295 Hagey Blvd., Suite 200 | Waterloo | AMER > > This message is intended only for the personal, confidential, and authorized > use of the recipient(s) named above. If you are not that person, you are not > authorized to review, use, copy, forward, distribute or otherwise disclose > the information contained in the message > > > On Tue, Sep 12, 2023 at 6:39 AM Ranen Ghosh <ranen.gh...@navblue.aero> wrote: > Hi, > > How does one use qt6_add_shaders in static libraries? When running an > application that uses said static library, we get this error messages like > this > > Failed to find shader "://shader.vert.qsb" > > We're using static linking because the target platform is iOS. On Windows > where we use dynamic linking, we have no problem. > > We follow this practice for qrc resources which works fine > "When embedding resources in static libraries,... explicitly register your > resources by calling Q_INIT_RESOURCE() with the base name of the .qrc file." > > https://doc.qt.io/qt-6/resources.html#explicit-loading-and-unloading-of-embedded-resources > > How does this relate to shaders added with qt6_add_shaders? From the > examples we have seen demonstrating qt6_add_resources, it does not seem to > involve qrc. For example, > > https://github.com/qt/qtshadertools/blob/26ffa67b0212255e29ec751bc25ebef65973ee99/tests/auto/buildtimeqsb/CMakeLists.txt > > qt6_add_shaders(tst_buildtimeqsb "shaders" > PREFIX > "/test" > FILES > "color.vert" > "color.frag" > ) > > https://github.com/qt/qtshadertools/blob/26ffa67b0212255e29ec751bc25ebef65973ee99/tests/auto/buildtimeqsb/tst_buildtimeqsb.cpp > > QShader color_vert = getShader(QLatin1String(":/test/color.vert.qsb")); > > (The URI does not have the qrc scheme) > > Thanks, > Ranen > -- > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development