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)?
You can use QMAKE_POST_LINK
to execute a copy command when the application is built. Just put this in your .pro file :
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))
}
}
}
You should add the paths for the files that you want to be copied to file_pathes
variable and the paths to the destination directories to destination_pathes
variable. Then all files would be copied to all the destinations when the application is built.
Here ffmpeg.exe
gets copied to application build and deploy directories in release mode and to build directory in debug mode.