user319862
user319862

Reputation: 1857

How to detect shared objects loaded by python ctypes

I need to copy shared objects into a package for distribution. Until this point, ldd was enough.

I've now encountered https://github.com/emcconville/wand/blob/master/wand/api.py which uses ctypes that ldd doesn't detect.

How can I detect what shared objects are loaded so that I can copy them?

Upvotes: 0

Views: 195

Answers (1)

There's no way to do this in general. Consider a program that did ctypes.util.find_library(sys.argv[1]). You can't possibly know ahead of time what libraries it will try to load.

In your specific case, you should be able to figure it out by wrapping ctypes to log all of the libraries it loads during execution. Note, though, that this will only work if your execution loads all of the libraries that it will ever need on any execution, so make sure you hit all relevant code paths.

Upvotes: 1

Related Questions