Missing symbol when creating a ressource in a shared library, the `dll` case
-
Dear
Qtusers and developpers,
I am trying to add a ressource in a dll.
I am usingcmakeas build system, but I don't thing that this is related to the issue.
I am adding the ressource in a shared library.qt_add_resources(TFELPlotResources_RCC TFELPlotResources.qrc) add_library(my_library SHARED ${TFELPlotResources_RCC})Later, I initialize the ressources in my main and link with the previous library. The problem is that the symbol
qInitResources_TFELPlotResourcesis not exported, causing a link error.On LiNuX, I can specify that all the symbols of the files listed in the
TFELPlotResources_RCCvariable shall be exported (-fvisibility=default). This works as expected.So on, I did not find a equivalent trick for Windows. Does anyone know how I shall proceed ?
Best regards,
Thomas Helfer
-
Dear
Qtusers and developpers,
I am trying to add a ressource in a dll.
I am usingcmakeas build system, but I don't thing that this is related to the issue.
I am adding the ressource in a shared library.qt_add_resources(TFELPlotResources_RCC TFELPlotResources.qrc) add_library(my_library SHARED ${TFELPlotResources_RCC})Later, I initialize the ressources in my main and link with the previous library. The problem is that the symbol
qInitResources_TFELPlotResourcesis not exported, causing a link error.On LiNuX, I can specify that all the symbols of the files listed in the
TFELPlotResources_RCCvariable shall be exported (-fvisibility=default). This works as expected.So on, I did not find a equivalent trick for Windows. Does anyone know how I shall proceed ?
Best regards,
Thomas Helfer
@thelfer I have found a solution. In juste created a function
initRessourcesin mydll, as follows:static void TFELPlotInitRessources(){ Q_INIT_RESOURCE(TFELPlotResources); } namespace tfel{ namespace plot{ void initRessources(){ ::TFELPlotInitRessources(); } // end of initRessources } // end of namespace plot } // end of namespace tfelNote that the
Q_INIT_RESOURCE(TFELPlotResources)must be in a function in the global namespace for reasons that I did not investiguate. I now have full control on the visibility of theìnitRessouresfunction.
I hope that this can be helpfull to otherQtusers.
Best regards,
Thomas Helfer