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. Resources from shared library
Forum Updated to NodeBB v4.3 + New Features

Resources from shared library

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 4.5k Views 2 Watching
  • 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.
  • S Offline
    S Offline
    silajim
    wrote on 19 Mar 2018, 23:47 last edited by
    #1

    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?

    A 1 Reply Last reply 20 Mar 2018, 03:52
    0
    • S silajim
      19 Mar 2018, 23:47

      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?

      A Offline
      A Offline
      ambershark
      wrote on 20 Mar 2018, 03:52 last edited by
      #2

      @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?

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      1
      • S Offline
        S Offline
        silajim
        wrote on 20 Mar 2018, 12:19 last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pablo J. Rogina
          wrote on 20 Mar 2018, 14:45 last edited by Pablo J. Rogina
          #4

          @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.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • S Offline
            S Offline
            silajim
            wrote on 20 Mar 2018, 14:51 last edited by
            #5

            @Pablo-J-Rogina No, I don't have a main in the library, that is the programs main.

            A 1 Reply Last reply 21 Mar 2018, 00:54
            0
            • S silajim
              20 Mar 2018, 14:51

              @Pablo-J-Rogina No, I don't have a main in the library, that is the programs main.

              A Offline
              A Offline
              ambershark
              wrote on 21 Mar 2018, 00:54 last edited by ambershark
              #6

              @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

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              1 Reply Last reply
              0

              1/6

              19 Mar 2018, 23:47

              • Login

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