I am trying to write a Qt application that will use QProcess
to call ffmpeg.exe
to convert media files. I cannot figure out the best way to make sure that the ffmpeg.exe
file gets copied from my development directory to the build directory so that the built (and later deployed) application will have access to it.
I have seen information about using the INSTALLS
parameter in my .pro file (https://stackoverflow.com/a/13168287) but the qmake docs say:
Note that qmake will skip files that are executable.
with all of the above said, how should one go about making sure that the exe file I want to use for QProcess
ends up in the build directory (ready to be deployed later)?
答案 0 :(得分:3)
构建应用程序时,可以使用QMAKE_POST_LINK
执行复制命令。只需将其放在.pro文件中:
win32:{
file_pathes += "\"$$PWD/Path/To/Files/ffmpeg.exe\""
CONFIG(release, debug|release):{
destination_pathes += $$OUT_PWD/release/
destination_pathes += Path/To/Deploy/Directory
}
else:CONFIG(debug, debug|release):{
destination_pathes += $$OUT_PWD/debug/
}
for(file_path,file_pathes){
file_path ~= s,/,\\,g
for(dest_path,destination_pathes){
dest_path ~= s,/,\\,g
QMAKE_POST_LINK += $$quote(xcopy $${file_path} $${dest_path} /I /Y $$escape_expand(\n\t))
}
}
}
您应该将要复制到file_pathes
变量的文件的路径和目标目录的路径添加到destination_pathes
变量。然后,在构建应用程序时,所有文件都将复制到所有目标。
此处ffmpeg.exe
被复制到应用程序构建并以发布模式部署目录,并以调试模式构建目录。