Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

qt

qmake

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?

like image 346
Rasmus Faber Avatar asked Nov 16 '09 07:11

Rasmus Faber


3 Answers

# 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.

like image 156
Wim Leers Avatar answered Nov 12 '22 14:11

Wim Leers


Add this to your pro file:

target.path = ../testProject/$$TARGET
INSTALLS += target 
like image 8
TimW Avatar answered Nov 12 '22 15:11

TimW


I use INSTALLS, like so. (qmake documentation)

like image 4
KeyserSoze Avatar answered Nov 12 '22 13:11

KeyserSoze