Table of Contents
This is a trick to copy QtDll alongside the executable, allowing to execute it outside QtCreator.
win32{
# applys only for windows
CONFIG(debug, debug|release){
DLL_SUFFIX=d.dll
} else {
DLL_SUFFIX=.dll
}
# copy QT dll, make sure path are with antislashes
DST_DIR_WIN = $${DESTDIR}
DST_DIR_WIN ~= s,/,\\,g
SRC_DIR_WIN = $$(QTDIR)\\bin\\
Qt5Core.name = Qt5Core$${DLL_SUFFIX}
Qt5Core.commands = $${QMAKE_COPY} $${SRC_DIR_WIN}$${Qt5Core.name} $${DST_DIR_WIN}\\$${Qt5Core.name}
Qt5Core.target = $${DESTDIR}/$${Qt5Core.name}
QMAKE_EXTRA_TARGETS += Qt5Core
PRE_TARGETDEPS += $${Qt5Core.target}
} # win32win32{
# applys only for windows
# needs : $${libFullpath} and $${libFullname} and $${DESTDIR}
# DLL copy rule
DLL_COPY_RULE.name = $${libFullname}.dll
DLL_COPY_RULE.source = $${libFullpath}/$${libFullname}.dll
DLL_COPY_RULE.target = $${DESTDIR}/$${DLL_COPY_RULE.name}
DLL_COPY_RULE.commands = $${QMAKE_COPY} $$shell_quote($$shell_path($${DLL_COPY_RULE.source})) $$shell_quote($$shell_path($${DLL_COPY_RULE.target}))
QMAKE_EXTRA_TARGETS += DLL_COPY_RULE
POST_TARGETDEPS += $${DLL_COPY_RULE.target}
}In pro file, you can manage different configuration between debug and release. To active release mode you have to add "CONFIG+=release" in qmqke commande line.
example:
qmake.exe C:\dev\flightManager\flightManager.pro -r -spec win32-g++ "CONFIG+=release"CONFIG(debug, debug|release){
BUILD_TYPE = debug
DEFINES += DEBUG
} else {
BUILD_TYPE = release
# Add stuff to avoid to open a windows black console when launching flight manager in release mode
CONFIG += gui windows core
CONFIG -= console
}# define the build root dir
BUILD_DIR = $${PWD}/build/$${BUILD_TYPE}
# and then the tree
DESTDIR = $${BUILD_DIR}/bim
OBJECTS_DIR = $${BUILD_DIR}/.obj
MOC_DIR = $${BUILD_DIR}/.moc
RCC_DIR = $${BUILD_DIR}/.rcc
UI_DIR = $${BUILD_DIR}/.ui