Frederik wrote: > On Wed, 11 Jun 2008 13:46:45 +0100, Andrew Haley wrote: > >> What does readelf -d test say? > > $ echo $LIBRARY_PATH > /cvos/shared/apps/gcc/gcc-4.2.4//lib:/cvos/shared/apps/boost/gcc-4.2/1.35.0/lib I'm not sure this will have any effect. > $ echo $LD_LIBRARY_PATH > /cvos/shared/apps/gcc/gcc-4.2.4//lib:/cvos/shared/apps/boost/gcc-4.2/1.35.0/lib:/cvos/shared/apps/sge/6.1/lib/lx26-amd64 This should work, though. > $ g++ -o test test.cpp -lboost_regex Use `gcc -v' here. Let's see what that says. > $ readelf -d test > > Dynamic section at offset 0xf778 contains 24 entries: > Tag Type Name/Value > 0x0000000000000001 (NEEDED) Shared library: [libboost_regex.so.2] Right, so it's liked against libboost_regex.so.2. The first instance of libboost_regex.so.2 that is found in LD_LIBRARY_PATH will be used. > $ ls -l /cvos/shared/apps/boost/gcc-4.2/1.35.0/lib/*regex* > lrwxrwxrwx 1 root root 27 Jun 11 12:22 /cvos/shared/apps/boost/gcc-4.2/1.35.0/lib/libboost_regex-mt.so -> libboost_regex-mt.so.1.35.0 > -rwxr-xr-x 1 root root 5881209 Jun 11 12:22 /cvos/shared/apps/boost/gcc-4.2/1.35.0/lib/libboost_regex-mt.so.1.35.0 > lrwxrwxrwx 1 root root 24 Jun 11 12:21 /cvos/shared/apps/boost/gcc-4.2/1.35.0/lib/libboost_regex.so -> libboost_regex.so.1.35.0 > -rwxr-xr-x 1 root root 5881164 Jun 11 12:21 /cvos/shared/apps/boost/gcc-4.2/1.35.0/lib/libboost_regex.so.1.35.0 > > So here I would have expected it to link against libboost_regex.so.1.35.0 > instead of libboost_regex_so.2. What am I doing wrong here? I'm not sure yet. Andrew. The linker uses the following search paths to locate required shared libraries: 1. Any directories specified by `-rpath-link' options. 2. Any directories specified by `-rpath' options. The difference between `-rpath' and `-rpath-link' is that directories specified by `-rpath' options are included in the executable and used at runtime, whereas the `-rpath-link' option is only effective at link time. Searching `-rpath' in this way is only supported by native linkers and cross linkers which have been configured with the `--with-sysroot' option. 3. On an ELF system, if the `-rpath' and `rpath-link' options were not used, search the contents of the environment variable `LD_RUN_PATH'. It is for the native linker only. 4. On SunOS, if the `-rpath' option was not used, search any directories specified using `-L' options. 5. For a native linker, the contents of the environment variable `LD_LIBRARY_PATH'. 6. For a native ELF linker, the directories in `DT_RUNPATH' or `DT_RPATH' of a shared library are searched for shared libraries needed by it. The `DT_RPATH' entries are ignored if `DT_RUNPATH' entries exist. 7. The default directories, normally `/lib' and `/usr/lib'. 8. For a native linker on an ELF system, if the file `/etc/ld.so.conf' exists, the list of directories found in that file.