J'ai un projet QT qui construit une bibliothèque DLL / Shared et un autre projet QT qui teste la bibliothèque. P>
Y a-t-il un bon moyen d'avoir QMake Copier la DLL au dossier de sortie du projet de test? P>
6 Réponses :
Cela peut ne pas être une «bonne» voie, mais cela peut faire le tour. P>
qmake_post_link + = une commande shell pour copier la DLL code> p>
Ajoutez ceci à votre fichier PRO:
target.path = ../testProject/$$TARGET INSTALLS += target
Cela ne fonctionne que si vous exécutez faire installer code> Étape de construction
Cela met la responsabilité sur le projet testé, de connaître le projet qui le teste - qui est en retard.
# 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.
Vous pouvez utiliser le mot-clé DEDIR CODE> car il est dit dans QMAKE Fichiers Documenttation dans Qt 4. P>
C'est l'inverse - Copie l'exécutable à Desdir Code> (où peut être). C'était un ajustement encore meilleur pour mon cas, merci pour l'indice.
QMAKE_POST_LINK += $$QMAKE_COPY $$quote("yourSrcDir\your.dll") $$quote($$IN_PWD) $$escape_expand(\\n\\t)