'Where does ctypes LoadLibrary() search for libs on OS X?
Where does ctypes
LoadLibrary() search for a shared lib on Mac OS X?
This works:
LoadLibrary("/full/path/to/my_library.dylib")
However,
LoadLibrary("my_library.dylib")
does not work, even /full/path/to)
is in PATH
and in PYTHONPATH
.
Solution 1:[1]
On OSX (as on (almost) any Nix), CTypes uses dlopen to open an .so (.dylib). According to [Apple.Developer]: DLOPEN(3) (or man dlopen) (emphasis is mine):
When path doesn't contain a slash character (i.e. it is just a leaf name), dlopen() searches the following until it finds a compatible Mach-O file: $LD_LIBRARY_PATH, $DYLD_LIBRARY_PATH, current working directory, $DYLD_FALLBACK_LIBRARY_PATH.
So, you could launch your script like (where %s mark placeholders):
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:%PATH_TO_YOUR_LIB_DIR% %COMMAND_LAUNCHING_SCRIPT%
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |