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. Qt resource not showing up in static build...
Forum Updated to NodeBB v4.3 + New Features

Qt resource not showing up in static build...

Scheduled Pinned Locked Moved Solved General and Desktop
42 Posts 5 Posters 14.9k Views 4 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.
  • mzimmersM mzimmers

    I wonder...is it possible that this isn't Qt's fault? That the fault is somewhere within the toolchain? I guess I could try to build my app on Linux or a Mac to see...that'll take a little time, though. Just an idea...

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by kshegunov
    #31

    Yes I guess it's a possibility, although probably a remote one. MSVC or MinGW? Because if it's mingw I'd expect it to behave pretty much the same as linux's g++. I'd compile it for you on linux, but the trouble is I don't keep static Qt builds around, I don't believe in static builds so to speak ...

    EDIT:
    Waaaaaiiit!
    Did you load the image plugins in your binary with Q_IMPORT_PLUGIN?

    Read and abide by the Qt Code of Conduct

    mzimmersM 1 Reply Last reply
    0
    • kshegunovK kshegunov

      Yes I guess it's a possibility, although probably a remote one. MSVC or MinGW? Because if it's mingw I'd expect it to behave pretty much the same as linux's g++. I'd compile it for you on linux, but the trouble is I don't keep static Qt builds around, I don't believe in static builds so to speak ...

      EDIT:
      Waaaaaiiit!
      Did you load the image plugins in your binary with Q_IMPORT_PLUGIN?

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #32

      @kshegunov it's MinGW. This isn't an area I'm especially knowledgeable in, but it seems that it's the toolchain (specifically the linker) that decides what does and doesn't go into an executable.

      By the way, if you avoid static images, how do you deliver standalone apps to customers?

      mrjjM kshegunovK 2 Replies Last reply
      0
      • mzimmersM mzimmers

        @kshegunov it's MinGW. This isn't an area I'm especially knowledgeable in, but it seems that it's the toolchain (specifically the linker) that decides what does and doesn't go into an executable.

        By the way, if you avoid static images, how do you deliver standalone apps to customers?

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #33

        @mzimmers said in Qt resource not showing up in static build...:

        By the way, if you avoid static images, how do you deliver standalone apps to customers?

        You can use an install maker
        to deliver the .exe and its support dlls.
        Qt even has its own tool
        http://doc.qt.io/qtinstallerframework/

        Static linking requires a Qt license so many of us , do it via an installer.

        1 Reply Last reply
        1
        • mzimmersM mzimmers

          @kshegunov it's MinGW. This isn't an area I'm especially knowledgeable in, but it seems that it's the toolchain (specifically the linker) that decides what does and doesn't go into an executable.

          By the way, if you avoid static images, how do you deliver standalone apps to customers?

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #34

          @mzimmers said in Qt resource not showing up in static build...:

          By the way, if you avoid static images, how do you deliver standalone apps to customers?

          One of the ways is to compile them in the binary, but as @mrjj noted you can also use an external (compiled) resource file and also you could possibly use an installer that delivers them raw in folders.
          What about the Q_IMPORT_PLUGIN question?

          Read and abide by the Qt Code of Conduct

          mzimmersM 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @mzimmers said in Qt resource not showing up in static build...:

            By the way, if you avoid static images, how do you deliver standalone apps to customers?

            One of the ways is to compile them in the binary, but as @mrjj noted you can also use an external (compiled) resource file and also you could possibly use an installer that delivers them raw in folders.
            What about the Q_IMPORT_PLUGIN question?

            mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #35

            @kshegunov I didn't see your plugin question until now...the answer is no, I didn't do that.

            What exactly is the plug-in here: the .svg file, or the .qrc file that identifies it?

            kshegunovK 1 Reply Last reply
            0
            • mzimmersM mzimmers

              @kshegunov I didn't see your plugin question until now...the answer is no, I didn't do that.

              What exactly is the plug-in here: the .svg file, or the .qrc file that identifies it?

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #36

              Aha, it may be the reason why it can't load the image; your issue might've been completely unrelated to the resource file.

              The plugin is a library - and extension to Qt - that is loaded when your program starts. Plugins provide means to access different 3rd party file/image formats, databases and such. It's usually not needed to care about it when you use dynamic Qt build, because Qt will take care to load it at the appropriate time, however because of technical reasons this is not possible when Qt is build statically (and with static plugins) and you need to do the initialization manually.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              1
              • mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #37

                So, I added this to main.cpp:

                    Q_IMPORT_PLUGIN(qsvg);
                

                And this to my .pro file:

                QTPLUGIN += qsvg
                

                I now get a build error:

                C:\Users\MZimmers\Qt projects\removed\main.cpp:-1: error: undefined reference to `qt_static_plugin_qsvg()'

                So, do I need to build and use a library in order to take advantage of this feature?

                kshegunovK L 2 Replies Last reply
                0
                • mzimmersM mzimmers

                  So, I added this to main.cpp:

                      Q_IMPORT_PLUGIN(qsvg);
                  

                  And this to my .pro file:

                  QTPLUGIN += qsvg
                  

                  I now get a build error:

                  C:\Users\MZimmers\Qt projects\removed\main.cpp:-1: error: undefined reference to `qt_static_plugin_qsvg()'

                  So, do I need to build and use a library in order to take advantage of this feature?

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #38

                  @mzimmers said in Qt resource not showing up in static build...:

                  So, do I need to build and use a library in order to take advantage of this feature?

                  Yes, the plugin itself. See what you have in <QtBase>/plugins/imageformats (I have a list of them one of which is libqsvg.so) you should have your plugins there (you'd expect to see .lib files)? If there are not then you haven't built them and that'd be the reason why the linker is complaining.

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • mzimmersM Offline
                    mzimmersM Offline
                    mzimmers
                    wrote on last edited by
                    #39

                    OK, I think we're zeroing in on this. My build of Qt with dynamic libraries is in:

                    C:\Qt\5.9.1\mingw53_32\plugins\imageformats

                    And all the .dlls are indeed there.

                    When I built my static version, I put it in \Qt\Static. Somehow, the 5.9.1 directory remained empty, but I do have a directory:

                    C:\Qt\Static\plugins\imageformats

                    With all the necessary .a files.

                    So, maybe the problem is that I screwed something up when I built my static version of Qt?

                    kshegunovK 1 Reply Last reply
                    0
                    • mzimmersM Offline
                      mzimmersM Offline
                      mzimmers
                      wrote on last edited by
                      #40

                      I think we have a solution:

                      I read the 5.0 version of the plugins doc: http://doc.qt.io/qt-5/plugins-howto.html. The wording is a little different, but it seems that the Q_IMPORT_PLUGIN is used when you want to create your own plugins, not use pre-existing ones. So I removed that file and it builds. The static version now displays the .svg.

                      Thanks to all who helped...

                      1 Reply Last reply
                      3
                      • mzimmersM mzimmers

                        OK, I think we're zeroing in on this. My build of Qt with dynamic libraries is in:

                        C:\Qt\5.9.1\mingw53_32\plugins\imageformats

                        And all the .dlls are indeed there.

                        When I built my static version, I put it in \Qt\Static. Somehow, the 5.9.1 directory remained empty, but I do have a directory:

                        C:\Qt\Static\plugins\imageformats

                        With all the necessary .a files.

                        So, maybe the problem is that I screwed something up when I built my static version of Qt?

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by kshegunov
                        #41

                        @mzimmers said in Qt resource not showing up in static build...:

                        With all the necessary .a files.

                        Nope, there's no error. MinGW uses linux-style static binaries (i.e. .a not .lib as with MSVC).
                        I'm glad you solved your problem in the meantime!

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0
                        • mzimmersM mzimmers

                          So, I added this to main.cpp:

                              Q_IMPORT_PLUGIN(qsvg);
                          

                          And this to my .pro file:

                          QTPLUGIN += qsvg
                          

                          I now get a build error:

                          C:\Users\MZimmers\Qt projects\removed\main.cpp:-1: error: undefined reference to `qt_static_plugin_qsvg()'

                          So, do I need to build and use a library in order to take advantage of this feature?

                          L Offline
                          L Offline
                          leashi
                          wrote on last edited by
                          #42

                          @mzimmers

                          qt5
                          in .pro QTPLUGIN += qsvg
                          in main.cpp Q_IMPORT_PLUGIN(QSvgPlugin)

                          qt4
                          in .pro QTPLUGIN += qsvg
                          in main.cpp Q_IMPORT_PLUGIN(qsvg)

                          name changed

                          1 Reply Last reply
                          0

                          • Login

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