Take a look at http://autopackage.org/docs/binreloc/ (http://autopackage.org/docs/binreloc/)
...that's a good one I didn't know to be honest. Anyway, for this minor purpose I read:
It's small, only about 20 KB of C source code (I suspect it's only about 10 KB if you remove all the inline documentation comments).
I wouldn't say for a self-allocation 10KB is small. Did you try the global variable hint? This works on all platforms and you have a minimalistic setup of 1 setting.
If you are using Boost.Filesystem this code will do it for you:
#include <iostream>
using namespace std;
#include <boost/filesystem/operations.hpp>
namespace bfs = boost::filesystem;
int main(int argc, char** argv)
{
cout << "My full path: " << bfs::current_path().string() << endl;
}
Its tested and it works like a charm. Gotta love boost.
Maybe we should check there implementation? Current_path uses getcwd (http://www.gnu.org/software/libc/manual/html_node/Working-Directory.html#index-getcwd-1382) on any Unix like platform. On Windows it uses GetCurrentDirectory (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getcurrentdirectory.asp). Or since we are using wxWidgets we can use wxGetCwd (http://www.wxwindows.org/manuals/2.6.3/wx_filefunctions.html#wxgetcwd) in wx/filefn.h. Which I just tested and it works exactly the same.
Both give you the full path from root.
EDIT: BinReloc listed above is cool because it will tell you where libraries and such are too.