It seems to me that Linux has it easy with /proc/self/exe. But I\'d like to know if there is a convenient way to find the current application\'s directory in C/C++ with cros
Well, of course, this doesn't apply to all projects.
Still, QCoreApplication::applicationFilePath()
never failed me in 6 years of C++/Qt development.
Of course, one should read documentation thoroughly before attempting to use it:
Warning: On Linux, this function will try to get the path from the /proc file system. If that fails, it assumes that argv[0] contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.
To be honest, I think that #ifdef
and other solutions like that shouldn't be used in modern code at all.
I'm sure that smaller cross-platform libraries also exist. Let them encapsulate all that platform-specific stuff inside.