In Ubuntu with C++, I have been given some code which creates an executable called Alpha. The code requires loading text files at runtime, and so there is a section of the code which finds the path of the executable, such that the relative directory containing these text files can be found. The executable path is determined by /proc/self/exe
.
Now, instead of creating the executable Alpha, I want to create a library called LibAlpha with the same code as Alpha, and then create another executable called Beta which calls LibAlpha. However, the problem with doing this using Alpha's original code, is that when /proc/self/exe
is called, it returns the path of Beta, rather than the path of LibAlpha. How can I get the path of the called library, rather than the executable?