Is it possible to retrieve programmatically and in a cross-platform way a list of the shared libraries (*.dll, *.so, *.dylib) linked to the current process?
For example:
vector<string> getLinkedSharedLibraries() {
// ...
}
vector<string> sharedLibraryList = getLinkedSharedLibraries();
for (list<string>::iterator it = sharedLibraryList.begin(); it != sharedLibraryList.end(); ++it)
cout << *it << endl;
which would return:
/usr/lib/libz.1.dylib
/usr/lib/libSystem.B.dylib
...
I was thinking about using OS commands such as ldd
on Linux and otool -L
on Mac, and then to eventually use [DY]LD_LIBRARY_PATH
to retrieve there absolute path. But I don't find a similar way on Windows.
Alternatively, is there any existing library doing such kind of thing?