/usr/lib似乎不是默认的链接位置 [英] /usr/lib appears not to be a default link location

查看:65
本文介绍了/usr/lib似乎不是默认的链接位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


经过进一步的挖掘后,我发现我在/usr/lib/i386-linux-gnu/libGL.so处有一个libGL.so,如果我将其移开,则链接将再次正常工作.在看了错误行一会儿之后,我认为消息中libGL.so的完整路径是可疑的,因为它将一直在多个位置查找它,并且通常只显示库的名称而不是一个特定的完整路径.小路.所以现在的问题是;为什么找到其他版本会导致搜索停止并显示令人困惑的错误消息? (我是i386ness,使其在某种程度上不兼容.)


After a bit more digging I have found that I have a libGL.so at /usr/lib/i386-linux-gnu/libGL.so and if I move this away then linking works correctly again. After looking at the error line for a while I thought that the full path to libGL.so in the message was suspicious because it would have been looking at multiple locations to find it and usually it only shows the name of the library not one specific full path. So the question now is; why did finding the other version cause the search to stop and show a confusing error message? (I'm the i386ness made it incompatible in some way).

原点:
由于某种原因,我无法将libGL.so链接到我的应用程序中.问题似乎是ld(在这种情况下为金)在/usr/lib中找不到(我能找到的是默认位置之一),而在usr/lib中寻找的却不是怪异的位置,例如

ORIG:
For some reason I am having trouble linking in libGL.so into my application. The issue seems to be that ld (or gold in this case) is not looking in /usr/lib (which from everything I can find is one of the default locations) when trying to find it instead it is looking in a bit of a whacky location e.g.

/usr/bin/ld:错误:无法打开/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libGL.so:否 这样的文件或目录

/usr/bin/ld: error: cannot open /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libGL.so: No such file or directory

现在/usr/lib/libGL.so确实存在,如果我在makefile中执行显式的-L/usr/lib,则所有链接都正确.

Now /usr/lib/libGL.so definitely exists and I if I do an explicit -L/usr/lib in the makefile everything links correctly.

我想知道有人知道这是怎么回事吗?

I'm wondering does anyone know what is going on here?

信息:
Ubuntu Linux 12.10 x86
g ++ 4.7
GNU黄金链接器
CPU AMD Phenom 2 x6
uname -m out:i686

Info:
Ubuntu linux 12.10 x86
g++ 4.7
GNU gold linker
CPU AMD Phenom 2 x6
uname -m out: i686

具有-v参数的链接的输出:

Output of link with -v parameter:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.7/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 
COMPILER_PATH=/usr/lib/gcc/i686-linux-gnu/4.7/:/usr/lib/gcc/i686-linux-gnu/4.7/:/usr/lib/gcc/i686-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.7/:/usr/lib/gcc/i686-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i686-linux-gnu/4.7/:/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.7/../../../../lib/:/lib/i386-linux-gnu/:/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/i686-linux-gnu/4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'application' '-v' '-L/home/user/src/tutorials/application/builds/./vendor/ogre3d/./lib' '-shared-libgcc' '-mtune=generic' '-march=i686'
 /usr/lib/gcc/i686-linux-gnu/4.7/collect2 --sysroot=/ --build-id --no-add-needed --as-needed --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -z relro -o application /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crti.o /usr/lib/gcc/i686-linux-gnu/4.7/crtbegin.o -L/home/user/src/tutorials/application/builds/./vendor/ogre3d/./lib -L/usr/lib/gcc/i686-linux-gnu/4.7 -L/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu -L/usr/lib/gcc/i686-linux-gnu/4.7/../../../../lib -L/lib/i386-linux-gnu -L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/i686-linux-gnu/4.7/../../.. /home/user/src/tutorials/application/builds/./src/most_basic_main.o /home/user/src/tutorials/application/builds/./src/QOgreWidget.o /home/user/src/tutorials/application/builds/./src/QtOgreApplication.o /home/user/src/tutorials/application/builds/./src/qt_gen/QtOgreApplication.moc.o /home/user/src/tutorials/application/builds/./src/qt_gen/QOgreWidget.moc.o -lpthread -lQtCore -lQtNetwork -lQtGui -lQtOpenGL -lRenderSystem_GLStatic -lOgreMainStatic -ldl -lfreetype -lXrandr -lGL -lGLU -lxcb -lX11 -lXext -lXpm -lXaw7 -lXt -lzzip -lfreeimage -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i686-linux-gnu/4.7/crtend.o /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crtn.o
/usr/bin/ld: error: cannot open /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libGL.so: No such file or directory

推荐答案

经过一番挖掘,结果证明我是悬挂的符号链接(基本上是一个不链接到有效对象的符号链接)的受害者.因此发生的是,链接器在/usr/lib/i386-linux-gnu/libGL.so处找到了libGL.so并确定其搜索结束了,但是,当它尝试获取该文件时,符号链接的末尾没有任何内容,从而导致出现错误消息:看到.一旦我删除了悬空的符号链接,搜索就没有找到libGL.so,直到它找到/usr/lib/libGL.so的正确版本为止,此时一切正常进行.

After a bunch of digging it turns out that I was the victim of a dangling symlink (which is basically a symlink that doesn't link to something valid). So what happened is that the linker found a libGL.so at /usr/lib/i386-linux-gnu/libGL.so and decided that its search was over, however when it tried to get at the file there was nothing at the end of the symlink which caused the error message that I was seeing. Once I removed the dangling symlink the search didn't find a libGL.so until it got to the correct version at /usr/lib/libGL.so at which point everything worked as it should.

这篇关于/usr/lib似乎不是默认的链接位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆