> On Thu, Jan 17, 2013 at 10:33 AM, Albert-Jan Roskam <fo...@yahoo.com> > wrote: >> >> The goal is to load the C libraries (dll, so, dylib, etc) that my program >> needs. >> >> Anyway, I looked up your two suggestions about library_dirs and >> runtime_library_dirs. What is meant by "at link time"? > > library_dirs adds search paths for the linker (e.g. ld) for finding > shared libraries (.so) and static libraries (.a archives of > relocatable object files). > > Linking to a shared library is handled by the runtime loader/linker > (e.g. /lib/ld-linux.so.2). For Linux, ld.so searches the > system-defined directories (/lib, /usr/lib, and those set by > /etc/ld.so.conf), which are cached in /etc/ld.so.cache (created by > ldconfig). This is where distutils runtime_library_dirs comes into > play. For ELF it configures an embedded RPATH, which the loader > searches before the system directories. You can also convert the RPATH > to a RUNPATH, which can be overridden by LD_LIBRARY_PATH.
Thank you! I am getting a whole lot wiser wrt Linux. I checked 'man ld' and 'man ldconfig'. Especially the ld command is pretty extensive. The Rpath/Runpath solution seems nice in that no wrapper is needed (contrary to when one uses LD_LIBRARY_PATH). But is Windows the only exception in the way that libraries are dealt with? Or do DLLs also have a dynamic area? >> Does this mean that the ELF header of the library itself is modified > > readelf -d shows the .dynamic section (including strings from > .dynstr), which you can use to verify the RPATH/RUNPATH. chrpath lets > you change (but not add) an RPATH, up to its existing length. It also > lets you convert an RPATH to a RUNPATH. patchELF can add or extend an > RPATH/RUNPATH. > > http://nixos.org/patchelf.html > >> The libraries I am using are copyrighted (one can freely use them, but >> no reverse engineering, disentangling, etc). I am not sure whether >> adding an rpath will be copyright infringement. Logically, I'd say no, >> but I doubt whether logic applies in legal stuff. > > It should be OK for internal administration. You'd have to ask a legal > expert about distribution. Yes, that would indeed be interesting to know. Unfortuntately, unlike developers, these folks are hard to get in touch with. Maybe theyŕe also a rare species. I think I'ĺl have to follow conservative approach here and not patch the ELF. > If you stick with LD_LIBRARY_PATH, etc, keep in mind it has to be set > before the process starts, typically in a wrapper script. On Windows, > however, you can modify PATH at runtime. So if, at runtime, I do something evil like del os.environ['PATH'] in Windows this actually deletes/propagates to my path?? Unlike other OS where os.environ is 'just' a dict that contains the paths, that once loaded, cannot be modified (well you can modify them, but the OS won know about the changes). _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor