trying to build standalone app
-
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...
-
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...
@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
-
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...
@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 buildyou can first build qt itself statically, and then build your app and the libexpat with that static version of qt
-
@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
-
@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 buildyou can first build qt itself statically, and then build your app and the libexpat with that static version of qt
-
@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?
-
@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.
@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.
-
@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.
-
@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.
-
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...
@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 yourexe's in the same folder. -
@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 yourexe's in the same folder.@kshegunov so there truly is no way to build an app that resides entirely within a single .exe file?
-
@kshegunov so there truly is no way to build an app that resides entirely within a single .exe file?
@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
dllfile and the MSVC linker reads it performs the symbol resolution (i.e. the linking) using it, not thedllitself. You can even link againstdlls without having the actualdlls present, only by using the import lib. It's unfortunate, but windows also uses the same extensionlibfor static libraries. So to link against adllyou have the stub and the shared library, while for static libraries only thelibfile. 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 ... -
Hi @mzimmers ,
Just to add one important piece for dynamic linking on Windows, which was not explicited state before, I think:
- The
*.libfile is needed at link time, it does not need to be deployed with the application - The
*.dllfile is needed at run time, it needs to be deployed
- The
-
Hi @mzimmers ,
Just to add one important piece for dynamic linking on Windows, which was not explicited state before, I think:
- The
*.libfile is needed at link time, it does not need to be deployed with the application - The
*.dllfile is needed at run time, it needs to be deployed
@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
.libfile is needed at link time, it does not need to be deployed with the application - The
*.dllfile 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 ;)
- The
-
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/releaseWhich 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?
-
Hi,
Are you trying to make a standalone debug application ?
-
Ok, I see. Then use
CONFIG(debug, debug|release){ # Debug specific stuff } else { # Release specific stuff } -
You have a
}just afterrelease.