I'm using the following code to get the current working directory of a C++ file
//Getting current working directory
getcwd( wd, 1024 );
std::string cwd = wd;
If the function in this file is called from another function, the current working directory becomes the path of the calling function.
How do I get the current directory of where the original file/binary is located?
I'm adding details as the question was confusing.
I've created a .so file which is called from Scilab. If I use readlink(), I get the path to be /usr/bin/scilab-bin
which is not what I want. How do I get the path of the so file, the current function is in?