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. trying to build standalone app
Forum Updated to NodeBB v4.3 + New Features

trying to build standalone app

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 6 Posters 3.5k 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

    Hi all -

    I'm trying to build a standalone Qt application. In my qmake.pro file, I have the following line:

    LIBS += "C:\Program Files (x86)\Expat 2.2.5\Bin\libexpat.lib"
    

    But when I try to run, I get this error:

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

    What would cause make to look for the .dll version of the library when I'm specifying the .lib version?

    Thanks...

    K Offline
    K Offline
    koahnig
    wrote on last edited by koahnig
    #2

    @mzimmers said in trying to build standalone app:

    LIBS += "C:\Program Files (x86)\Expat 2.2.5\Bin\libexpat.lib"
    

    Typically you should use forward slashes '/' .AFAIK '\' is interpret as escape sequence.

    But when I try to run, I get this error:

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

    What would cause make to look for the .dll version of the library when I'm specifying the .lib version?

    You are probably linking to the so-called stub-library. Under windows you generate for each dll also the lib holding stubs indicating how the access to the dll routines has to be.

    [edit, koahnig] This might give a better explanation

    Vote the answer(s) that helped you to solve your issue(s)

    mzimmersM 1 Reply Last reply
    5
    • mzimmersM mzimmers

      Hi all -

      I'm trying to build a standalone Qt application. In my qmake.pro file, I have the following line:

      LIBS += "C:\Program Files (x86)\Expat 2.2.5\Bin\libexpat.lib"
      

      But when I try to run, I get this error:

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

      What would cause make to look for the .dll version of the library when I'm specifying the .lib version?

      Thanks...

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #3

      @mzimmers hi,
      You need to put the dll in your app executable folder.
      If you want everything in your .exe file you have to do static build

      you can first build qt itself statically, and then build your app and the libexpat with that static version of qt

      mzimmersM 1 Reply Last reply
      1
      • K koahnig

        @mzimmers said in trying to build standalone app:

        LIBS += "C:\Program Files (x86)\Expat 2.2.5\Bin\libexpat.lib"
        

        Typically you should use forward slashes '/' .AFAIK '\' is interpret as escape sequence.

        But when I try to run, I get this error:

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

        What would cause make to look for the .dll version of the library when I'm specifying the .lib version?

        You are probably linking to the so-called stub-library. Under windows you generate for each dll also the lib holding stubs indicating how the access to the dll routines has to be.

        [edit, koahnig] This might give a better explanation

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

        @koahnig so even though I'm copying over the lib file, I need to copy the dll, too? That's not really very standalone, is it?

        K 1 Reply Last reply
        0
        • ODБOïO ODБOï

          @mzimmers hi,
          You need to put the dll in your app executable folder.
          If you want everything in your .exe file you have to do static build

          you can first build qt itself statically, and then build your app and the libexpat with that static version of qt

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

          @LeLev I'm trying to do a static build. I've built a static version of Qt, but my app build doesn't seem to be static. I must be missing a step.

          K ODБOïO 2 Replies Last reply
          0
          • mzimmersM mzimmers

            @koahnig so even though I'm copying over the lib file, I need to copy the dll, too? That's not really very standalone, is it?

            K Offline
            K Offline
            koahnig
            wrote on last edited by
            #6

            @mzimmers

            AFAIK this is only for windows. I get confused on linux ;)

            For windows, either you have one lib or you have a lib and a dll. If you got both you need the lib for liniking and the dll for execution.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            1
            • mzimmersM mzimmers

              @LeLev I'm trying to do a static build. I've built a static version of Qt, but my app build doesn't seem to be static. I must be missing a step.

              K Offline
              K Offline
              koahnig
              wrote on last edited by
              #7

              @mzimmers said in trying to build standalone app:

              @LeLev I'm trying to do a static build. I've built a static version of Qt, but my app build doesn't seem to be static. I must be missing a step.

              AFAIK you can mix. If there is one stub lib, you will need also the dll for that stub lib.

              Vote the answer(s) that helped you to solve your issue(s)

              mzimmersM 1 Reply Last reply
              1
              • mzimmersM mzimmers

                @LeLev I'm trying to do a static build. I've built a static version of Qt, but my app build doesn't seem to be static. I must be missing a step.

                ODБOïO Offline
                ODБOïO Offline
                ODБOï
                wrote on last edited by
                #8

                @mzimmers you need static version of your lib also

                1 Reply Last reply
                2
                • K koahnig

                  @mzimmers said in trying to build standalone app:

                  @LeLev I'm trying to do a static build. I've built a static version of Qt, but my app build doesn't seem to be static. I must be missing a step.

                  AFAIK you can mix. If there is one stub lib, you will need also the dll for that stub lib.

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

                  @koahnig yeah, that was it...I moved both the .lib and the .dll file, and it runs. Thanks for the information about those stub libraries; I'd never heard of that.

                  1 Reply Last reply
                  0
                  • mzimmersM mzimmers

                    Hi all -

                    I'm trying to build a standalone Qt application. In my qmake.pro file, I have the following line:

                    LIBS += "C:\Program Files (x86)\Expat 2.2.5\Bin\libexpat.lib"
                    

                    But when I try to run, I get this error:

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

                    What would cause make to look for the .dll version of the library when I'm specifying the .lib version?

                    Thanks...

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

                    @mzimmers said in trying to build standalone app:

                    What would cause make to look for the .dll version of the library when I'm specifying the .lib version?

                    Nothing. This is a loader error, not a linker error. You need to deploy the dependent libraries along with the application binary. On windows this most often means package the dlls alongside your exe's in the same folder.

                    Read and abide by the Qt Code of Conduct

                    mzimmersM 1 Reply Last reply
                    3
                    • kshegunovK kshegunov

                      @mzimmers said in trying to build standalone app:

                      What would cause make to look for the .dll version of the library when I'm specifying the .lib version?

                      Nothing. This is a loader error, not a linker error. You need to deploy the dependent libraries along with the application binary. On windows this most often means package the dlls alongside your exe's in the same folder.

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

                      @kshegunov so there truly is no way to build an app that resides entirely within a single .exe file?

                      kshegunovK 1 Reply Last reply
                      0
                      • mzimmersM mzimmers

                        @kshegunov so there truly is no way to build an app that resides entirely within a single .exe file?

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

                        @mzimmers said in trying to build standalone app:

                        so there truly is no way to build an app that resides entirely within a single .exe file?

                        There is, however you must provide all the dependent libraries as static. On windows there's something called "import library" (or "stub library" as you got to know it above). This is only for linking purposes. What it does is basically state what kind of symbols are contained in the dll file and the MSVC linker reads it performs the symbol resolution (i.e. the linking) using it, not the dll itself. You can even link against dlls without having the actual dlls present, only by using the import lib. It's unfortunate, but windows also uses the same extension lib for static libraries. So to link against a dll you have the stub and the shared library, while for static libraries only the lib file. I believe that's where your confusion stems from.

                        Now back to how linking's done. If you have linked with an import library the linker will put a statement in the dll header that a specific dll is to be loaded. This happens when you start the program. There's a "utility" called the loader, which's responsible for loading the required modules and then transferring control to your main(). When you link statically there's no such first step of loading modules done, as the static binary is directly "injected" into your application. If, however, your static library depends on a dynamic one, this also propagates to your application; meaning that even if you built Qt statically, but you haven't used static libraries as its dependencies your application will include Qt's binary code, but it's going to still depend dynamically on Qt's dependencies.

                        To have a "completely" stand-alone application you need to provide the whole tree of dependencies as static libraries. Then the linker can merge all the static code into one executable and it won't require dlls at load-time. This, beware, implies that you also need to provide even the C-runtime as a static library (in case of MSVC - the visual C runtime - msvcrt), which can be a real pain ...

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        6
                        • aha_1980A Offline
                          aha_1980A Offline
                          aha_1980
                          Lifetime Qt Champion
                          wrote on last edited by aha_1980
                          #13

                          Hi @mzimmers ,

                          Just to add one important piece for dynamic linking on Windows, which was not explicited state before, I think:

                          • The *.lib file is needed at link time, it does not need to be deployed with the application
                          • The *.dll file is needed at run time, it needs to be deployed

                          Qt has to stay free or it will die.

                          K 1 Reply Last reply
                          4
                          • aha_1980A aha_1980

                            Hi @mzimmers ,

                            Just to add one important piece for dynamic linking on Windows, which was not explicited state before, I think:

                            • The *.lib file is needed at link time, it does not need to be deployed with the application
                            • The *.dll file is needed at run time, it needs to be deployed
                            K Offline
                            K Offline
                            koahnig
                            wrote on last edited by
                            #14

                            @aha_1980 said in trying to build standalone app:

                            Hi @mzimmers ,

                            Just to add one important piece for dynamic linking on Windows, which was not explicited state before, I think:

                            • The .lib file is needed at link time, it does not need to be deployed with the application
                            • The *.dll file is neede at run time, it needs to be deployed

                            @koahnig said in trying to build standalone app:

                            @mzimmers
                            For windows, either you have one lib or you have a lib and a dll. If you got both you need the lib for liniking and the dll for execution.

                            I acknowledge, a bit hidden ;)

                            Vote the answer(s) that helped you to solve your issue(s)

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

                              Still fooling around with this...I borrowed the code below from somewhere:

                              myown_installs.files = "C:/Program Files (x86)/Expat 2.2.5/Bin/libexpat.lib" \
                              	"C:/Program Files (x86)/Expat 2.2.5/Bin/libexpat.dll"
                              myown_installs.path = $$OUT_PWD/release
                              

                              Which works fine for my builds to the /release subdirectory, but not for debugs. Is there some clever way to conditionalize this in my project file?

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

                                Hi,

                                Are you trying to make a standalone debug application ?

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

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

                                  Hi - no, but when I try to run the debugger, it crashes because these files aren't in the build directory.

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

                                    Ok, I see. Then use

                                    CONFIG(debug, debug|release){
                                        # Debug specific stuff
                                    } else {
                                        # Release specific stuff
                                    }
                                    

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

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

                                      I get a very unexpected error from this:0_1548282879804_creator.PNG

                                      Any idea what I'm doing wrong?

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

                                        You have a } just after release.

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

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

                                          Oh, brother...I'd downvote myself for that if I could.

                                          It works fine now...thanks, SGaist.

                                          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