摆脱“gcc -/usr/bin/ld: warning lib not found"; [英] Get rid of "gcc - /usr/bin/ld: warning lib not found"

查看:19
本文介绍了摆脱“gcc -/usr/bin/ld: warning lib not found";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在链接过程中收到以下警告:

I have the following warning during link:

/usr/bin/ld: warning: libxxx.so.6, needed by /a/b/c/libyyy.so, not found (try using -rpath or -rpath-link)

设置环境变量 LD_LIBRARY_PATH=path_to_libxxx.so.6 使警告静音(添加 -Lpath_to_libxxx.so.6 没有帮助).

Setting environment variable LD_LIBRARY_PATH=path_to_libxxx.so.6 silence the warning (adding -Lpath_to_libxxx.so.6 doesn't help).

我有一个单独的编译服务器,只编译生成的二进制文件.二进制文件在其他服务器上执行,二进制文件可以看到 libxxx.so.6(使用 ldd 可执行文件 检查).

I have a separate compilation server, where the resulting binary is only compile. The binary is executed on other server and there the libxxx.so.6 is seen by the binary (checked with ldd executable).

有没有其他方法可以消除编译时的警告(我有好几次了,很烦人)?

Is there're other way to get rid of the warning at compilation time (I have it several times and it's very annoying)?

推荐答案

你需要添加-L等价的动态库:

You need to add the dynamic library equivalent of -L:

-Wl,-rpath-link,/path/to/lib

这会导致链接器在非标准的地方寻找共享库,但只是为了验证链接是否正确.

This will cause the linker to look for shared libraries in non-standard places, but only for the purpose of verifying the link is correct.

如果您希望程序在运行时在那个位置找到库,那么有一个类似的选项可以做到这一点:

If you want the program to find the library at that location at run-time, then there's a similar option to do that:

-Wl,-rpath,/path/to/lib

但是,如果你的程序在没有这个的情况下运行良好,那么你就不需要它了.

But, if your program runs fine without this then you don't need it.

这篇关于摆脱“gcc -/usr/bin/ld: warning lib not found";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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