I built a local version of OpenGL under my home directory. I want to link another shared library against it, but for some reason the linker still links it against the one under /usr/lib, as reported by ldd:
$ cc -o lib/libtfont.so -shared -Wl,-soname,/home/wknight/proj/wkl/tfont.lib/lib/libtfont.so tfont.o -L/home/wknight/proj/wkl/img.lib/lib -limg -L/home/wknight/swtools/opengl/lib -lGL -lGLU $ ldd lib/libtfont.so linux-gate.so.1 => (0xb7710000) /home/wknight/proj/wkl/img.lib/lib/libimg.so (0xb76fc000) libGL.so.1 => /usr/lib/libGL.so.1 (0xb7689000) libGLU.so.1 => /usr/lib/libGLU.so.1 (0xb7618000) libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb74d1000) libX11.so.6 => /usr/lib/libX11.so.6 (0xb73b4000) libXext.so.6 => /usr/lib/libXext.so.6 (0xb73a5000) libXxf86vm.so.1 => /usr/lib/libXxf86vm.so.1 (0xb73a0000) libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0xb739c000) libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0xb7397000) libdrm.so.2 => /usr/lib/libdrm.so.2 (0xb738d000) libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7367000) libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb734e000) libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7349000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7254000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7236000) /lib/ld-linux.so.2 (0xb7711000) libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb721d000) librt.so.1 => /lib/i686/cmov/librt.so.1 (0xb7214000) libXau.so.6 => /usr/lib/libXau.so.6 (0xb7211000) libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb720b000) $ ls -l /home/wknight/swtools/opengl/lib/libGL* lrwxrwxrwx 1 wknight wknight 10 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGL.so -> libGL.so.1 lrwxrwxrwx 1 wknight wknight 12 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGL.so.1 -> libGL.so.1.2 -rwxr-xr-x 1 wknight wknight 1836469 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGL.so.1.2 lrwxrwxrwx 1 wknight wknight 11 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGLU.so -> libGLU.so.1 lrwxrwxrwx 1 wknight wknight 20 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGLU.so.1 -> libGLU.so.1.3.070900 -rwxr-xr-x 1 wknight wknight 1634905 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGLU.so.1.3.070900 lrwxrwxrwx 1 wknight wknight 11 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGLw.so -> libGLw.so.1 lrwxrwxrwx 1 wknight wknight 15 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGLw.so.1 -> libGLw.so.1.0.0 -rwxr-xr-x 1 wknight wknight 37068 Jan 25 16:57 /home/wknight/swtools/opengl/lib/libGLw.so.1.0.0 $
This happens even if I rename my local version of libGL.so and link against the new name. So something is happening behind the scenes that I don't understand. Is the linker looking in ld.so.cache or something? How can I override it?