Note that there are some explanatory texts on larger screens.

plurals
  1. POProgramatically determine shared libraries in use by running application
    text
    copied!<p>Is it possible to (and, if so, how does one) determine the shared libraries of an application that are used by an application <em>at runtime</em>? Basically, can I programmatically obtain the the output of <code>ldd</code>? Preferred C/C++ solution does not just jump to execute ldd on the command-line.</p> <p>Consider the following: I have a driver application that calls <code>doAction()</code> from a shared library <code>libfoo</code>. I compile the application once and then set <code>LD_LIBRARY_PATH</code> to an appropriate directory containing a <code>libfoo</code> with the <code>doAction()</code> symbol defined. This way, I can have multiple implementations of <code>doAction()</code> in different <code>libfoo</code>s but only ever compile an application once.</p> <p>A real world example would be a professor having a class of students implement <code>doAction()</code>. Instead of compiling a test harness against each student's implementation of <code>doAction()</code>, the students submit a shared library and the professor can simply change <code>LD_LIBRARY_PATH</code> to evaluate each student.</p> <p>My goal in obtaining the library currently being used is to perform an <code>md5sum</code> on the library at runtime to ensure I'm calling the correct library. In the contrived example, all students would submit the <code>md5sum</code> of their library and the professor could match the running executable + shared library (database lookup, log to file, ...) to the student, to prevent an accident in setting <code>LD_LIBRARY_PATH</code> effecting another student's grade (forgot to change <code>LD_LIBRARY_PATH</code> to David's directory and ran again with Bill's <code>libfoo</code>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload