问题
I've recently been "compiling" python scripts into binary form for the purpose of internal distribution. I'm using the utility cx_freeze which, in it's default state, creates a directory with the primary binary executable in it as well as a bunch of binary *.so files. My understanding is that .so files are libraries, and they are obviously necessary to get the executable binary to function, but my question is how can I link stuff together so they don't all have to be in the same directory? Do I have to determine that at "compile time"? Is there a universal path variable that the executables will look in for libraries it might need, or is that path stated somewhere in the executable itself?
Thanks in advance!
回答1:
The shared objects are searched for by the dynamic linker in a number of locations as explained in the dynamic linker's manpage for linux or OSX:
DT_RPATH
attribute stored in the binary for ELF files.LD_LIBRARY_PATH
environment variable if the executable isn't set-user-id/set-group-id.DT_RUNPATH
attribute stored in the binary for ELF files./etc/ld.so.cache
file which serves as library path cache for the dynamic linker.- Finally, the default directories
/lib
and/usr/lib
.
来源:https://stackoverflow.com/questions/9542357/how-do-so-files-work-and-where-do-they-go-in-unix