Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Missing symbol when creating a ressource in a shared library, the `dll` case
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 592 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thelfer
    wrote on last edited by
    #1

    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.

    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_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

    T 1 Reply Last reply
    0
    • T thelfer

      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.

      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_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

      T Offline
      T Offline
      thelfer
      wrote on last edited by thelfer
      #2

      @thelfer I have found a solution. In juste created a function initRessources in my dll, 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 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

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved