Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. static building with 3rd party library
Qt 6.11 is out! See what's new in the release blog

static building with 3rd party library

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
11 Posts 3 Posters 1.6k Views 3 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 Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I posted about this awhile back, and had it working, but upon updating to 5.14.1 and doing a rebuild, the problem has recurred.

    I need to build a static, standalone app that uses a 3rd-party library (expat). I've added this to my .pro file:

    expatInstallsDebug.files = "C:/Program Files (x86)/Expat 2.2.5/Bin/libexpat.dll"
    expatInstallsDebug.path = $$OUT_PWD
    
    expatInstallsRelease.files = "C:/Program Files (x86)/Expat 2.2.5/Bin/libexpat.lib"
    expatInstallsRelease.path = $$OUT_PWD
    
    INSTALLS += expatInstallsDebug expatInstallsRelease
    

    And added a "make install" step to my build. Now my dynamic build works. But when I build static, and remove the .exe from its directory, I get an error:

    The code execution cannot proceed because libexpat.dll was not found. Reinstalling the program may fix this problem.

    It appears that I need to add some logic in my .pro file that is debug/release specific. Can someone suggest how I might best accomplish this?

    Thanks...

    kshegunovK 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Hi all -

      I posted about this awhile back, and had it working, but upon updating to 5.14.1 and doing a rebuild, the problem has recurred.

      I need to build a static, standalone app that uses a 3rd-party library (expat). I've added this to my .pro file:

      expatInstallsDebug.files = "C:/Program Files (x86)/Expat 2.2.5/Bin/libexpat.dll"
      expatInstallsDebug.path = $$OUT_PWD
      
      expatInstallsRelease.files = "C:/Program Files (x86)/Expat 2.2.5/Bin/libexpat.lib"
      expatInstallsRelease.path = $$OUT_PWD
      
      INSTALLS += expatInstallsDebug expatInstallsRelease
      

      And added a "make install" step to my build. Now my dynamic build works. But when I build static, and remove the .exe from its directory, I get an error:

      The code execution cannot proceed because libexpat.dll was not found. Reinstalling the program may fix this problem.

      It appears that I need to add some logic in my .pro file that is debug/release specific. Can someone suggest how I might best accomplish this?

      Thanks...

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

      @mzimmers said in static building with 3rd party library:

      It appears that I need to add some logic in my .pro file that is debug/release specific. Can someone suggest how I might best accomplish this?

      CONFIG(static, shared|static): // Stuff for static
      
      CONFIG(debug, debug|release): // Stuff for debug
       
      CONFIG(release, debug|release): // Stuff for release
      
      

      Read and abide by the Qt Code of Conduct

      mzimmersM 1 Reply Last reply
      1
      • kshegunovK kshegunov

        @mzimmers said in static building with 3rd party library:

        It appears that I need to add some logic in my .pro file that is debug/release specific. Can someone suggest how I might best accomplish this?

        CONFIG(static, shared|static): // Stuff for static
        
        CONFIG(debug, debug|release): // Stuff for debug
         
        CONFIG(release, debug|release): // Stuff for release
        
        
        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @kshegunov thanks. I've read the documentation about the CONFIG variable; seems kind of like a Swiss army knife -- lots of uses. I still don't understand the syntax (in terms of how to fully form the CONFIG statement) but I'm guessing I need to use the "link_prl" option somehow?

        I'm starting to remember a previous go with this...I think you were one of the people who helped me. I seem to recall problems with using the .lib directly, and needing the .dll. You provided a rather elaborate solution, the details of which I can't recall nor find by searching this forum. Does this ring a bell with you?

        kshegunovK 1 Reply Last reply
        0
        • mzimmersM mzimmers

          @kshegunov thanks. I've read the documentation about the CONFIG variable; seems kind of like a Swiss army knife -- lots of uses. I still don't understand the syntax (in terms of how to fully form the CONFIG statement) but I'm guessing I need to use the "link_prl" option somehow?

          I'm starting to remember a previous go with this...I think you were one of the people who helped me. I seem to recall problems with using the .lib directly, and needing the .dll. You provided a rather elaborate solution, the details of which I can't recall nor find by searching this forum. Does this ring a bell with you?

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

          @mzimmers said in static building with 3rd party library:

          I've read the documentation about the CONFIG variable; seems kind of like a Swiss army knife -- lots of uses.

          Yes, it has.

          I still don't understand the syntax (in terms of how to fully form the CONFIG statement)

          It's a sort of string matching machinery.

          CONFIG(debug, debug|release): # evaluates to true if debug is present in CONFIG out of the possible `debug` and `release` values
          

          I'm starting to remember a previous go with this...I think you were one of the people who helped me. I seem to recall problems with using the .lib directly, and needing the .dll. You provided a rather elaborate solution, the details of which I can't recall nor find by searching this forum. Does this ring a bell with you?

          Usually it's the other way around, but it may be and I've just forgotten. I have no recollection of it, sorry.

          Read and abide by the Qt Code of Conduct

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

            Found it!

            link text

            I'm using MinGW (not MSVC). Are the C-runtime libraries available in static form, or do I need to build them?

            Perhaps I should stop focusing on building the standalone app, and instead just supplying a .msi style installation?

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              IIRC, you would also have to rebuild Qt itself to use the static runtime (at least that's what you have to do with Visual Studio). You have four option static/shared using static/shared runtime. I am not sure MinGW provides the equivalent for the runtime part.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              mzimmersM kshegunovK 2 Replies Last reply
              1
              • SGaistS SGaist

                Hi,

                IIRC, you would also have to rebuild Qt itself to use the static runtime (at least that's what you have to do with Visual Studio). You have four option static/shared using static/shared runtime. I am not sure MinGW provides the equivalent for the runtime part.

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

                @SGaist I use -static -static-runtime in my configure command; is that what you're talking about?

                1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi,

                  IIRC, you would also have to rebuild Qt itself to use the static runtime (at least that's what you have to do with Visual Studio). You have four option static/shared using static/shared runtime. I am not sure MinGW provides the equivalent for the runtime part.

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

                  @SGaist said in static building with 3rd party library:

                  I am not sure MinGW provides the equivalent for the runtime part.

                  No not that I know of. MinGW uses a thin wrapper around the MS C runtime, but I don't believe you can instruct it to link the msvcrt statically. I think the best that can be accomplished is to force it to not depend on its wrapper dynamically.

                  @mzimmers said in static building with 3rd party library:

                  Are the C-runtime libraries available in static form, or do I need to build them?

                  If you mean the microsoft's runtime, yes, they're available. But I don't think there's a straightforward (or any) way to use them with mingw.

                  Perhaps I should stop focusing on building the standalone app, and instead just supplying a .msi style installation?

                  That's what'd be my preferred method, honestly. Static binaries have some advantages (and disadvantages), but my personal preference is to just deploy with dynamic libraries.

                  I use -static -static-runtime in my configure command; is that what you're talking about?

                  Yes, that's the two relevant flags.

                  Read and abide by the Qt Code of Conduct

                  mzimmersM 1 Reply Last reply
                  1
                  • kshegunovK kshegunov

                    @SGaist said in static building with 3rd party library:

                    I am not sure MinGW provides the equivalent for the runtime part.

                    No not that I know of. MinGW uses a thin wrapper around the MS C runtime, but I don't believe you can instruct it to link the msvcrt statically. I think the best that can be accomplished is to force it to not depend on its wrapper dynamically.

                    @mzimmers said in static building with 3rd party library:

                    Are the C-runtime libraries available in static form, or do I need to build them?

                    If you mean the microsoft's runtime, yes, they're available. But I don't think there's a straightforward (or any) way to use them with mingw.

                    Perhaps I should stop focusing on building the standalone app, and instead just supplying a .msi style installation?

                    That's what'd be my preferred method, honestly. Static binaries have some advantages (and disadvantages), but my personal preference is to just deploy with dynamic libraries.

                    I use -static -static-runtime in my configure command; is that what you're talking about?

                    Yes, that's the two relevant flags.

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

                    @kshegunov yeah, I suppose you're right. I have one customer who likes things as simple as possible, and to him, simple equates to a single .exe file that he can move anywhere. He's a HW engineer, incipiently mistrustful of SW, and more so when it gets what he perceives as complicated. But...maybe it's time I reminded him that Clinton's out of office, and times have changed.

                    I'm really close to getting this to work, though...the only file that my .exe needs is the libexpat.dll. If I move that file with my .exe it runs.

                    kshegunovK 1 Reply Last reply
                    0
                    • mzimmersM mzimmers

                      @kshegunov yeah, I suppose you're right. I have one customer who likes things as simple as possible, and to him, simple equates to a single .exe file that he can move anywhere. He's a HW engineer, incipiently mistrustful of SW, and more so when it gets what he perceives as complicated. But...maybe it's time I reminded him that Clinton's out of office, and times have changed.

                      I'm really close to getting this to work, though...the only file that my .exe needs is the libexpat.dll. If I move that file with my .exe it runs.

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

                      @mzimmers said in static building with 3rd party library:

                      @kshegunov yeah, I suppose you're right. I have one customer who likes things as simple as possible, and to him, simple equates to a single .exe file that he can move anywhere. He's a HW engineer, incipiently mistrustful of SW, and more so when it gets what he perceives as complicated. But...maybe it's time I reminded him that Clinton's out of office, and times have changed.

                      Comes with the territory, I guess. As a physicist, I don't put much faith in engineers either ... although I must admit my reservations are mostly misguided ...

                      I'm really close to getting this to work, though...the only file that my .exe needs is the libexpat.dll. If I move that file with my .exe it runs.

                      Hm, is that a Qt dependency, or one of your own? I don't recall deploying it ...

                      Read and abide by the Qt Code of Conduct

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

                        expat is a 3rd party library XML parser. It's built into the IDF for my target processor (with which my Qt program communicates), so I just decided to use it with Qt as well.

                        1 Reply Last reply
                        2

                        • Login

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