Copy Dependencies with windeployqt
# Deployment - Automatically Detect and Copy Dependencies to Build Folder
TARGET_CUSTOM_EXT = .exe
DEPLOY_COMMAND = windeployqt
CONFIG( debug, debug|release ) {
# debug
DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/debug/$${TARGET}$${TARGET_CUSTOM_EXT}))
} else {
# release
DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/release/$${TARGET}$${TARGET_CUSTOM_EXT}))
}
# Uncomment the following line to help debug the deploy command when running qmake
#warning($${DEPLOY_COMMAND} $${DEPLOY_TARGET})
QMAKE_POST_LINK = $${DEPLOY_COMMAND} $${DEPLOY_TARGET}
或 Copy dependencies manually
# Deployment - Copy Dependencies to Build Folder
dlls.path = $${DESTDIR}
dlls.files += $$[QT_INSTALL_BINS]/icudt51.dll
dlls.files += $$[QT_INSTALL_BINS]/icuin51.dll
dlls.files += $$[QT_INSTALL_BINS]/icuuc51.dll
dlls.files += $$[QT_INSTALL_BINS]/libgcc_s_dw2-1.dll
dlls.files += $$[QT_INSTALL_BINS]/libstdc++-6.dll
dlls.files += $$[QT_INSTALL_BINS]/libwinpthread-1.dll
dlls.files += $$[QT_INSTALL_BINS]/Qt5Core.dll
dlls.files += $$[QT_INSTALL_BINS]/Qt5Network.dll
dlls.files += $$[QT_INSTALL_BINS]/Qt5Gui.dll
dlls.files += $$[QT_INSTALL_BINS]/Qt5Widgets.dll
dllA.path += $${DESTDIR}/platforms
dllA.files += $$[QT_INSTALL_PLUGINS]/platforms/qwindows.dll
dllB.path += $${DESTDIR}/plugins/imageformats/
dllB.files += $$[QT_INSTALL_PLUGINS]/imageformats/qico.dll
dllB.files += $$[QT_INSTALL_PLUGINS]/imageformats/qwbmp.dll
INSTALLS += dlls dllA dllB
如果您需要跨平台识别先决条件/依赖项,请查看CMake的 getPrerequisites() . 它使用 dumpbin , objbin , ldd , otool 来识别依赖项 .