Get executable path on linux
-
wrote on 16 Oct 2021, 21:27 last edited by hbatalha
My app uses a custom build of ffmpeg that I keep the in the app install location so it doesn't conflicts with the official ffmpeg in case user has it in his machine.
I want to get its install location and for that I use, like in Windows, QString QDir::currentPath() but the problem I am facing is that I am installing the program through a deb package and so by my tests QDir::currentPath() will point to the location of the deb file since it is the parent of my app executable because deb installation creates a symbolic link of the my app executable to
/usr/bin/
.Right now I install my app in
/opt/my_app_name/
and I could set current path there but, even though unlikely. the user might change that location and I need to know where my executable is so I can determine the ffmpeg location and avoid errors.I hope I made myself clear.
-
wrote on 17 Oct 2021, 04:52 last edited by
QDir::currentPath() is not the location of the application, it is the running application's current working directory. This, even on Windows, can be anywhere.
QCoreApplication::applicationDirPath() is your best bet.
-
QDir::currentPath() is not the location of the application, it is the running application's current working directory. This, even on Windows, can be anywhere.
QCoreApplication::applicationDirPath() is your best bet.
1/3