|
From: | Daniel Reed |
Subject: | Re: totally confused by versioning system of libtool... |
Date: | Fri, 13 May 2005 11:16:01 -0400 (EDT) |
On Fri, 13 May 2005, Ed Hartnett wrote:
Bob Friesenhahn <address@hidden> writes:On Fri, 13 May 2005, Ed Hartnett wrote:How does the version number get used in this situation? That is, is there any time on the users machine that the linker notices that he is now linking to 1.0.0 instead of 0.0.0?That implies that when I install a new version, the old version says around. Is that correct? Then, if the user re-links his program, the linker will find the most recent version of the library to link to? Is that correct?
In general, the linker will look for the file libexample.so, which is usually created as a symlink to libexample.so.0 or libexample.so.1 or whatever was most recently installed (not necessarily newest).
If the program is linked using -lexample while libexample.so points to libexample.so.1, the program will expect to be able to find libexample.so.1 when it is run.
If the program is linked while libexample.so points to libexample.so.0, it will expect to find libexample.so.0 when it is run, even if libexample.so is changed to point to libexample.so.1 in the mean time.
When linking the program inside a Libtool wrapper (using "libtool --mode=link gcc -o program -lexample" instead of just "gcc -o program -lexample"), the existence of a file libexample.la can cause Libtool to override the linker's default behavior, having it explicitly link to libexample.so.0 even if libexample.so points to libexample.so.1, or whatever, as in:
address@hidden:~/cc# gcc blah.c -o blah -L. -lexample address@hidden:~/cc# LD_LIBRARY_PATH=. ldd blah libexample.so.1 => ./libexample.so.1 (0xb7fe9000) libc.so.6 => /lib/libc.so.6 (0xb7ea4000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fec000) address@hidden:~/cc# rm blah address@hidden:~/cc# libtool --mode=link gcc blah.c -o blah -L. -lexample gcc blah.c -o blah -L/root/cc /root/cc/libexample.so.0 -Wl,--rpath -Wl,/root/cc -Wl,--rpath -Wl,/root/cc address@hidden:~/cc# ldd blah libexample.so.0 => /root/cc/libexample.so.0 (0xb7fe9000) libc.so.6 => /lib/libc.so.6 (0xb7ea4000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fec000) address@hidden:~/cc# -- Daniel Reed <address@hidden> http://naim-users.org/nmlorg/ http://naim.n.ml.org/ It is so easy to miss pretty trivial solutions to problems deemed complicated. The goal of a scientist is to find an interesting problem, and live off it for a while. The goal of an engineer is to evade interesting problems :) -- Vadim Antonov <address@hidden> on NANOG
[Prev in Thread] | Current Thread | [Next in Thread] |