问题
I have a Qt-based application that uses a number of dlls that are built outside of the project. These dlls are checked into source because we will not be rebuilding them very frequently (they take on the order of hours to build, I don't want those to be in the main project). I want to copy those dlls into the appropriate directories (release, debug) once building has occurred. Is there a way to incorporate that copy step into the .pro file, so that the copying is propagated to each machine that uses the code? The suggestion I've found in places like this is to use a post-build step and build a batch file, but post-build steps are not shared between machines (they are stored in the .pro.user file, which is machine specific).
I've tried using something like:
Debug:POST_TARGETDEPS = ../../Dir1/Dir2/bin/mylib.dll
But that doesn't copy the file into the debug directory nor into the DESTDIR directory.
回答1:
You will want to use the INSTALLS
keyword and then make sure when you build you do a make install
.
dlls_to_move.path = $$DESTDIR
dlls_to_move.files += ../../Dir1/Dir2/bin/mylib.dll
INSTALLS += dlls_to_move
You can find more information on INSTALLS in the QMake documentation.
来源:https://stackoverflow.com/questions/6285687/how-can-i-copy-dll-files-to-the-output-directory-in-qt-not-using-qtcreator