Unsolved Resources from shared library
-
I am in the process of creating a Shared library that includes several resource files (*.qrc). While the library works correctly statically linked and the qrc's declared in the main exe, when converted into a Shared library the library itself cannot access the it's own resource files.
I tried using Q_INIT_RESOURCE either on the main.cpp and on the library itself, all without any kind of luck. It's giving me a link error: undefined reference to `qInitResources_fonts_xml()'
Any ideas on what is going on?
-
@silajim Can we see the code where you call
Q_INIT_RESOURCE
?Also what is the name of your qrc file? Is it fonts_xml? Are you building the resources into the dll or did you forget to include them in the project file?
-
@ambershark here is the snipet
int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); Q_INIT_RESOURCE(fonts_xml); ... }
The name of the qrc is fonts_xml.qrc and yes I am building it into the dll, with
RESOURCES += $$files(*.qrc, false)
on the pro file.
-
@silajim are you having a main() in your shared library? or is it just for testing? I guess shared libraries don't need/have a main().
In addition, you may want to check these answers here and there in SO regarding resource naming clash to avoid (between your shared library and the application using it) just in case.
-
@Pablo-J-Rogina No, I don't have a main in the library, that is the programs main.
-
@silajim said in Resources from shared library:
@Pablo-J-Rogina No, I don't have a main in the library, that is the programs main.
Ok so at some point you actually need to call that in your library code. Not a main() since obviously libs don't have a main.
Here is another thread I just helped on with the exact problem you are having. It is solved now, maybe the answers there can help you out.
https://forum.qt.io/topic/88959/undefined-reference-to-qinitresources/5