我在我的主目录下构建了一个本地版本的 OpenGL。我想将另一个共享库链接到它,但由于某种原因,链接器仍然将它链接到 /usr/lib 下的共享库,正如 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 $
即使我重命名本地版本的 libGL.so 并链接到新名称,也会发生这种情况。所以在幕后发生了一些我不明白的事情。链接器是在寻找 ld.so.cache 还是什么?我怎样才能覆盖它?