|
From: Lalatendu Das on 2 Jul 2008 08:30 When I run a binary, how come it knows about what are the default path. I know that when binary need to search for shared objects at run time binary sees first LD_LIBARAY_PATH then RPATH then the default path. So the question is if LD_LIBARAY_PATH and RPATH aren't set which component tells the runtime linker to search the library in the /usr/ lib or /lib that is nothing but the fefault path. Is it set during the compilation phase of the binary? if yes then what intermediate step of compilation phase does that ? thanks in advance.
From: Doug McIntyre on 2 Jul 2008 09:47 Lalatendu Das <lalatdas(a)gmail.com> writes: >When I run a binary, how come it knows about what are the default >path. I know that when binary need to search for shared objects at run >time binary sees first LD_LIBARAY_PATH then RPATH then the default >path. >So the question is if LD_LIBARAY_PATH and RPATH aren't set which >component tells the runtime linker to search the library in the /usr/ >lib or /lib that is nothing but the fefault path. >Is it set during the compilation phase of the binary? if yes then what >intermediate step of compilation phase does that ? You are entering system dependencies areas here. Different OSs have different rules. There's a 3rd library path for the default libs, but its system dependent. On Solaris, you'd use crle to manage the system wide default library path. Also on Solaris, RPATH is always set in in each executable, its pretty much a given, and LD_LIBRARY_PATH is very deprecetiated for use on Solaris. On some linux dists, you'd edit up /etc/ld.so.conf and /etc/ld.so.conf.d/* files to set the system library paths for various things, and RPATH doesn't seem to exist in most binaries. I believe some linux, that the default ld.so.conf has the default paths built into it. FreeBSD4 has just /etc/ld.so.conf, while FreeBSD7 has ldconfig much like the Solaris crle. Other OSs all have other means. You'll find the dynamic linker is probably the most different subsystem on most different OSs.
From: Jens Thoms Toerring on 2 Jul 2008 09:53 Lalatendu Das <lalatdas(a)gmail.com> wrote: > When I run a binary, how come it knows about what are the default > path. I know that when binary need to search for shared objects at run > time binary sees first LD_LIBARAY_PATH then RPATH then the default > path. > So the question is if LD_LIBARAY_PATH and RPATH aren't set which > component tells the runtime linker to search the library in the /usr/ > lib or /lib that is nothing but the fefault path. > Is it set during the compilation phase of the binary? if yes then what > intermediate step of compilation phase does that ? I don't know which system you're and the details could differ... Under e.g. Linux the default settings for the runtime loader are in /etc/ld.so.conf. If you change it (or install new libraries) you have to run 'ldconfig' which creates a database of all lib- raries in the dafault directories (/etc/ld/so.cache) which then is used for locating the necessary libraries. Regards, Jens -- \ Jens Thoms Toerring ___ jt(a)toerring.de \__________________________ http://toerring.de
|
Pages: 1 Prev: what 64 mean in fopen64? Next: Please help me in writing script |