qmake: How do I copy .dll/.so's to the output directory?

烂漫一生 提交于 2019-12-29 06:45:08

问题


I have a Qt-project that builds a dll/shared-library and another Qt-project that tests the library.

Is there any good way to have qmake copy the dll to the output-folder of the test-project?


回答1:


Add this to your pro file:

target.path = ../testProject/$$TARGET
INSTALLS += target 



回答2:


# Copy the dynamic library.
win32 {
   QMAKE_PRE_LINK=copy /Y lib\qextserialport\src\build\qextserialportd.dll debug\ & copy /Y lib\qextserialport\src\build\qextserialport.dll release\
}
else {
   # TODO: Unices
}

This works, for the QextSerialPort library. Supports Qt's debug_and_release mode.

QMAKE_POST_LINK also works, but will throw an error if you're trying to run the app immediately: then your .dll will be copied too late. QMAKE_PRE_LINK does copy it in time.




回答3:


I use INSTALLS, like so. (qmake documentation)




回答4:


This may not be a 'good' way but it may do the trick.

QMAKE_POST_LINK += some shell command to copy the dll




回答5:


You can use DESTDIR keyword as it is said in qmake files documetation in Qt 4.




回答6:


QMAKE_POST_LINK += $$QMAKE_COPY $$quote("yourSrcDir\your.dll") $$quote($$IN_PWD) $$escape_expand(\\n\\t)


来源:https://stackoverflow.com/questions/1740534/qmake-how-do-i-copy-dll-sos-to-the-output-directory

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