Frederik wrote: > I've got different versions of the boost libraries installed on my > system: one is installed system wide in /usr/lib64, while other versions > are installed in /cvos/shared/apps/boost/gcc-4.[123]/1.35.0, compiled > with the respective different versions of gcc. > > When I want to use one of the custom built libraries, I set the CPATH, > LIBRARY_PATH and LD_LIBRARY_PATH variables to the respective include > files and libraries. > > For the gcc 4.1 one, this works correctly: > $ g++ -o test test.cpp -lboost_regex > $ ldd test | grep boost > libboost_regex.so.1.35.0 => /cvos/shared/apps/boost/ > gcc-4.1/1.35.0/lib/libboost_regex.so.1.35.0 (0x00007f2352ad1000) > > And without the environment vars set, it links against the one in /usr/ > lib64: > libboost_regex.so.2 => /usr/lib64/libboost_regex.so.2 > (0x00007fb000918000) What does readelf -d test say? > However when I do exactly the same with gcc 4.2 and gcc 4.3, it always > links against the libboost_regex.so.2 on in /usr/lib64 and not against > the libboost_regex.so.1.35.0 in /cvos/shared/apps/boost/gcc-4.[23]/1.35.0/ > lib, even though the LIBRARY_PATH and LD_LIBRARY_PATH variables have this > directory set as first. > > The versions used are gcc 4.1.2 20070626 (Red Hat 4.1.2-14), stock gcc > 4.2.4 and stock gcc 4.3.1. > > Has this behaviour changed in gcc 4.2, or is it something RH specific > which makes that it works with my gcc 4.1? This is nothing to do with gcc: it's controlled by the shared library loader /lib/ld-linux.so, which is part of glibc. Andrew.