-
I'm developing a Qt app that requires executing another executable with some arguments. The code I use to call this utility is: QProcess process;
QString executablePath;
QStringList arguments{"--unpack_raw_blk", "--stdout", "--stdin", "--format", "Json"};
#ifdef Q_OS_WIN
executablePath = "./wt_ext_cli.exe";
#elif defined(Q_OS_LINUX)
executablePath = "$APPDIR/usr/bin/wt_ext_cli";
#else
throw std::runtime_error("Unsupported platform");
#endif
process.start(executablePath, arguments);
if (!process.waitForStarted()) {
throw std::runtime_error("Failed to start process");
} On Windows I simply copy the .exe to the release folder and it works. For Linux I tried copying it into the /usr/bin folder and invoking it by both "/usr/bin/wt_ext_cli" and "wt_ext_cli" but still says "Failed to start process". Is there a way to achieve this or I am simply making some errors in the code? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Construct
This might work for all operating systems, as long as both executables are in the same directory. Also, it is not AppImage specific. |
Beta Was this translation helpful? Give feedback.
-
The solution was referencing the binary as if it was in the same directory and setting binary permissions to execute it: file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/wt_ext_cli/wt_ext_cli DESTINATION ${DEPLOY_PREFIX_PATH}/usr/bin FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) |
Beta Was this translation helpful? Give feedback.
The solution was referencing the binary as if it was in the same directory and setting binary permissions to execute it: