/usr/bin/ld: 警告:找不到 xyz.so 所需的 abc.so(尝试使用 -rpath 或 -rpath-link)”
我正在构建一个 C++ 应用程序,使用 Netbeans 6.9 作为我的 IDE。我有一个 C++ 库,它是纯 C 库的包装器。
我已将文件正确添加到项目中(使用“添加库文件”选项)。以下是 g++ 和链接器生成的输出:
g++ -o dist/Debug/GNU-Linux-x86/testluaembed build/Debug/GNU-Linux-x86/src/main.o build/Debug/GNU-Linux-x86/src/LuaBinding.o -L../../mainline/tanlib_core/dist/Debug/GNU-Linux-x86 -L../../mainline/tanlib++/dist/Debug/GNU-Linux-x86 -L/usr/lib ../../mainline/tanlib_core/dist/Debug/GNU-Linux-x86/libtanlib_core.so ../../mainline/tanlib++/dist/Debug/GNU-Linux-x86/libtanlibpp.so /usr/lib/liblua5.1.a /usr/lib/libtolua++5.1.a /usr/local/boost_1_45_0/stage/lib/libboost_filesystem.a /usr/local/boost_1_45_0/stage/lib/libboost_system.a
/usr/bin/ld: warning: libtanlib_core.so, needed by ../../mainline/tanlib++/dist/Debug/GNU-Linux-x86/libtanlibpp.so, not found (try using -rpath or -rpath-link)
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `gctm':
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/testluaembed] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
我在 C++ 包装器库上运行 ldd 并得到以下输出:
$ldd libtanlibpp.so
linux-vdso.so.1 => (0x00007fff123c0000)
libtanlib_core.so => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fe4f0fde000)
libm.so.6 => /lib/libm.so.6 (0x00007fe4f0d5a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fe4f0b43000)
libc.so.6 => /lib/libc.so.6 (0x00007fe4f07c0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe4f15ee000)
因此,虽然该文件存在于我的计算机上,但它似乎不在我的库缓存中。我尝试使用 ldconfig,但问题仍然存在。关于如何解决这个问题有什么想法吗?
I am building a C++ application, using Netbeans 6.9 as my IDE. I have a C++ library which is a wrapper around a pure C library.
I have correctly added the file to the project (using the Add Library File option). Here is the output produced by g++ and the linker:
g++ -o dist/Debug/GNU-Linux-x86/testluaembed build/Debug/GNU-Linux-x86/src/main.o build/Debug/GNU-Linux-x86/src/LuaBinding.o -L../../mainline/tanlib_core/dist/Debug/GNU-Linux-x86 -L../../mainline/tanlib++/dist/Debug/GNU-Linux-x86 -L/usr/lib ../../mainline/tanlib_core/dist/Debug/GNU-Linux-x86/libtanlib_core.so ../../mainline/tanlib++/dist/Debug/GNU-Linux-x86/libtanlibpp.so /usr/lib/liblua5.1.a /usr/lib/libtolua++5.1.a /usr/local/boost_1_45_0/stage/lib/libboost_filesystem.a /usr/local/boost_1_45_0/stage/lib/libboost_system.a
/usr/bin/ld: warning: libtanlib_core.so, needed by ../../mainline/tanlib++/dist/Debug/GNU-Linux-x86/libtanlibpp.so, not found (try using -rpath or -rpath-link)
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `ll_loadfunc':
/usr/lib/liblua5.1.a(loadlib.o): In function `gctm':
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/testluaembed] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
I run ldd on the C++ wrapper library and got this output:
$ldd libtanlibpp.so
linux-vdso.so.1 => (0x00007fff123c0000)
libtanlib_core.so => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fe4f0fde000)
libm.so.6 => /lib/libm.so.6 (0x00007fe4f0d5a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fe4f0b43000)
libc.so.6 => /lib/libc.so.6 (0x00007fe4f07c0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe4f15ee000)
So although the file exists on my machine, it appears it is not in my library cache. I tried using ldconfig, but the problem remains. Any ideas on how to resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保在
/etc/ld.so.conf
(或/etc/ld.so.conf.d)中配置了放置
) - 否则libtanlib_core.so
的目录/ldconfig
将找不到它。Make sure the directory where
libtanlib_core.so
is placed is configured in/etc/ld.so.conf
(or/etc/ld.so.conf.d/
) - otherwiseldconfig
will not find it.