qmake: copy qt dlls to output directory
I googled this question but didn't find any working solution.
Eventually I decided to ask it once again.
Can anybody provide me with a WORKING example of pro-file that copies qt dlls into output directory?
I tried this:
Code:
CONFIG += qt release
SOURCES += src/main.cpp
message($(QTDIR)) # output: c:\Qt\4.8.4_vs2008\
# Method 1
qt_libs.path=release
qt_libs.files=$(QTDIR)bin/QtCore4.dll
INSTALLS += qt_libs
# Method 2
EXTRA_BINFILES += $(QTDIR)bin/QtCore4.dll
EXTRA_OUT_FILES += release
for(FILE,EXTRA_BINFILES){
QMAKE_POST_LINK += $$quote(cp $${FILE} $$EXTRA_OUT_FILES $$escape_expand(\\n\\t))
}
But it also doesn't work.
$(QTDIR) suddenly becomes empty. Although message($(QTDIR)) above produces a valid path to qt installations.
Re: qmake: copy qt dlls to output directory
Have you tried using "$$(QTDIR)" (note the double dollar) at line 8? This should embed the value of the QTDIR environment variable into the Makefile rather than looking for the value at the time you run the Makefile.
Your second option won't work on a Windows machine because "cp" is a UNIX copy command.
This approach works on Linux without relying on an external QTDIR variable, and should also do so on Windows with appropriate name changes:
Code:
qtlibs.path = release
qtlibs.files += $$[QT_INSTALL_LIBS]/libQtCore.so
qtlibs.files += $$[QT_INSTALL_LIBS]/libQtGui.so
INSTALLS += qtlibs