How can I copy dll files to the output directory in Qt not using QtCreator?

穿精又带淫゛_ 提交于 2019-12-10 17:29:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!