Missing symbol when creating a ressource in a shared library, the `dll` case

  • Dear Qt users and developpers,
    I am trying to add a ressource in a dll.
    I am using cmake as build system, but I don't thing that this is related to the issue.
    I am adding the ressource in a shared library.

    add_library(my_library SHARED

    Later, I initialize the ressources in my main and link with the previous library. The problem is that the symbol qInitResources_TFELPlotResources is not exported, causing a link error.

    On LiNuX, I can specify that all the symbols of the files listed in the TFELPlotResources_RCC variable 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 initRessources in my dll, as follows:

    static void TFELPlotInitRessources(){
    namespace tfel{
      namespace plot{
        void initRessources(){
        } // end of initRessources
      } // end of namespace plot
    } // end of namespace tfel

    Note 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 ├ČnitRessoures function.
    I hope that this can be helpfull to other Qt users.
    Best regards,
    Thomas Helfer

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.