Copying .dlls into target directory
-
Hi, JKSH -
- I mean third-party libraries. These are to be found in the MinGW directory tree.
- here are a few answers:
other answers
the first suggestion is more complicated than I want to try, and the second answer doesn't work because it says that the extra_libs.path path isn't defined. (Do I need to define DESTDIR myself? I thought it was a built-in variable. - yes.
Thank you.
-
The answers in your link were complicated because the asker wanted everything done automatically. This is not strictly necessary (but it does save you a minute or so each time you want to deploy)
From the Windows command line, do this:
- Navigate to the folder which contains your Qt DLLs
- Add the MinGW directory to your PATH
- Run the deployment tool, tell it where to find your built executable (see http://doc.qt.io/qt-5/windows-deployment.html)
Example: (Assumes that you installed Qt into
C:\Qt
, that you're using Qt 5.6.2,, and that you have compiled your app intoD:\Projects\MyApp\build-MyApp-Desktop_Qt_5_6_2_MinGW_32bit-Release\release
)> cd C:\Qt\5.6\mingw49_32\bin > set path=%path%;C:\Qt\Tools\mingw492_32\bin > windeployqt.exe D:\Projects\MyApp\build-MyApp-Desktop_Qt_5_6_2_MinGW_32bit-Release\release
-
Thank you both.
I think I prefer the solution proposed by VRonin, mainly because I understand it better. Unfortunately, I'm getting this error when I try to build:
:-1: warning: C:/Qt/5.7/mingw53_32/bin\libgcc_s_dw2-1.dll.path is not defined: install target not created
The path is definitely there, and the file exists. What am I doing wrong?
Thanks...
-
Hi, Vronin -
I fixed that problem by following the syntax used in the examples I posted above (with the .path and the .files).
Now I get no errors, but the file still doesn't move to the target directory (in this case, the debug directory).
.pro file:
TEMPLATE = app CONFIG += CONSOLE CONFIG -= qt TARGET = storefile SOURCES += \ storefile_client.cpp #win32:QMAKE_CXXFLAGS += /MD HEADERS += \ storefile_client.h \ win32:LIBS += "C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\ws2_32.lib" INCLUDEPATH += "../ARM/inc/" win32 { libsto_copy.files += $$QMAKE_LIBDIR_QT/libgcc_s_dw2-1.dll } libs_to_copy.path = $$OUT_PWD/$$OUTDIR INSTALLS += libs_to_copy #INSTALLS += $$[QT_INSTALL_BINS]\libgcc_s_dw2-1.dll #INSTALLS += C:\Qt\5.7\mingw53_32\bin\libgcc_s_dw2-1.dll
Thank you.
-
fixed the typo; still doesn't work:
TEMPLATE = app CONFIG += CONSOLE CONFIG -= qt TARGET = storefile SOURCES += \ storefile_client.cpp #win32:QMAKE_CXXFLAGS += /MD HEADERS += \ storefile_client.h \ win32:LIBS += "C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\ws2_32.lib" INCLUDEPATH += "../ARM/inc/" libs_to_copy.files = $$QMAKE_LIBDIR_QT/libgcc_s_dw2-1.dll libs_to_copy.path = $$OUT_PWD/$$OUTDIR INSTALLS += libs_to_copy #INSTALLS += $$[QT_INSTALL_BINS]\libgcc_s_dw2-1.dll #INSTALLS += C:\Qt\5.7\mingw53_32\bin\libgcc_s_dw2-1.dll
Oddly enough, it's copying the .o file, but not the .dll I want.
-
Hi
Im wondering if mixing/ and \ is ok? C:/Qt/5.7/mingw53_32/bin\libgcc_s_dw2-1.dll. ^
-
@mrjj said in copying .dlls into target directory:
Hi
Im wondering if mixing/ and \ is ok? C:/Qt/5.7/mingw53_32/bin\libgcc_s_dw2-1.dll. ^
Good question. In my hard-coded tests, I tried it with all "/" and all "" and get the same error, though.
Does qmake have some kind of echo function where I can output the value of variables?
Thanks.
-
Ok, was just a thought.
You can outout withmessage($$VAR)
-
Well, I'm still stuck on this. The problem appears to be in this area:
DESTDIR = $$(OUT_PWD) extra_libs.files = MY_LIB_FILES extra_libs.path = $$(DESTDIR) ## Tell qmake to add the moving of them to the 'install' target INSTALLS += extra_libs
I get this error (warning):
:-1: warning: extra_libs.path is not defined: install target not created
OUT_PWD appears to be OK. I don't really know what I'm doing with the variable "extra_lib" as that was just yanked from an example above. I assumed the .files and .path were properties of the variable, but now I'm questioning what I'm doing.
Anyone able to shed some light onto this?
Thanks.
UPDATE:
I just clicked on the "see more replies" part of the answer I was trying to copy -- someone claims that INSTALLS doesn't work on Windows. Can anyone confirm or deny this? I don't find anything about this limitation in the docs. I tried invoking the make from the command line, and got this:
C:\Qt\Tools\mingw530_32\bin>.\mingw32-make.exe install mingw32-make: *** No rule to make target 'install'. Stop.
So I guess it is true...?
-
Try using hard-coded paths first and see if you can get that to work. After you succeed, replace the hard-coded paths with variables.
(I haven't used INSTALLS before and don't currently have access to a computer to try it myself)
-
well I was under the impression that make install was a unix thing as doc mentioned but
then i read that mingw-make does have "install". I have however never tried it.But the plugandpaint example has
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint
INSTALLS += target
which maps to
C:/Qt/Examples/Qt-5.7/widgets/tools/plugandpaint
But nothing is copied there so Im not sure it does work. -
well I was under the impression that make install was a unix thing as doc mentioned but
then i read that mingw-make does have "install". I have however never tried it.But the plugandpaint example has
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint
INSTALLS += target
which maps to
C:/Qt/Examples/Qt-5.7/widgets/tools/plugandpaint
But nothing is copied there so Im not sure it does work.@mrjj said in copying .dlls into target directory:
well I was under the impression that make install was a unix thing as doc mentioned but
No, it's a
make
thing. Any self-respecting make implementation (including MS'snmake
) should provide the install target out of the box. :)But the plugandpaint example has
Well, how did you install? Did you call
make install
(or equivalent) from the Qt source's base path? If not, you've erred, because there's a chain ofpro
files (andmkspec
s and other goodies that get included and ultimately theQT_INSTALL_EXAMPLES
is set for you). But anyway, that's another matter altogether.I suggest you run
qmake
manually with-d
or-d -d
to get some debug info back. It is possible that the qmake's makefile generator doesn't respect theINSTALLS
variable (although I see no reason it shouldn't).Kind regards.
-
@kshegunov - thank you for the suggestion. I tried this and got ~6700 error messages; I'm not sure I did it correctly.
I do have another question: my build steps are to run make first, then qmake. If qmake is a "meta-make" tool, shouldn't the order be 1) qmake and 2) make?
Thank you.
-
@kshegunov - thank you for the suggestion. I tried this and got ~6700 error messages; I'm not sure I did it correctly.
I do have another question: my build steps are to run make first, then qmake. If qmake is a "meta-make" tool, shouldn't the order be 1) qmake and 2) make?
Thank you.
-
Well, somehow they got switched (I probably fat-fingered it). I put them in the correct order (qmake, make, make install) and still it doesn't copy the files. Here's the compiler output:
08:42:17: Running steps for project storefile_client... 08:42:17: Configuration unchanged, skipping qmake step. 08:42:17: Starting: "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" C:/Qt/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug' g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -I..\storefile_client -I. -I..\ARM\inc -IC:\Qt\5.7\mingw53_32\mkspecs\win32-g++ -o debug\storefile_client.o ..\storefile_client\storefile_client.cpp g++ -Wl,-subsystem,console -mthreads -o debug\storefile.exe debug/storefile_client.o "C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\ws2_32.lib" mingw32-make[1]: Leaving directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug' 08:42:18: The process "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" exited normally. 08:42:18: Starting: "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" install C:/Qt/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug install mingw32-make[1]: Entering directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug' **mingw32-make[1]: Nothing to be done for 'install'.** mingw32-make[1]: Leaving directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug' 08:42:19: The process "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" exited normally. 08:42:19: Elapsed time: 00:02.
To my layman eyes, it's looking more like the make that comes with mingw doesn't honor installs?
-
Well, somehow they got switched (I probably fat-fingered it). I put them in the correct order (qmake, make, make install) and still it doesn't copy the files. Here's the compiler output:
08:42:17: Running steps for project storefile_client... 08:42:17: Configuration unchanged, skipping qmake step. 08:42:17: Starting: "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" C:/Qt/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug' g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -I..\storefile_client -I. -I..\ARM\inc -IC:\Qt\5.7\mingw53_32\mkspecs\win32-g++ -o debug\storefile_client.o ..\storefile_client\storefile_client.cpp g++ -Wl,-subsystem,console -mthreads -o debug\storefile.exe debug/storefile_client.o "C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\ws2_32.lib" mingw32-make[1]: Leaving directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug' 08:42:18: The process "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" exited normally. 08:42:18: Starting: "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" install C:/Qt/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug install mingw32-make[1]: Entering directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug' **mingw32-make[1]: Nothing to be done for 'install'.** mingw32-make[1]: Leaving directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug' 08:42:19: The process "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" exited normally. 08:42:19: Elapsed time: 00:02.
To my layman eyes, it's looking more like the make that comes with mingw doesn't honor installs?
Honestly, I have no idea. Could you attach the make file and the pro you're currently using?