Search code examples
c++linuxunixdirectorycwd

C++ Get Application Directory *NIX


How can I get the application directory in C++ on Linux/Unix. getcwd() returns the directory from which the application was run, but I want the actual directory which the build is sitting in.

I know you can get this from the main() but I dont really have access to it, and I've been told you cant rely on it (Is that true?).


Solution

  • You can see this answer:

    c++ - Finding current executable's path without /proc/self/exe - Stack Overflow