大量warning:libb.so needed by liba.so not found.的问题解决方法

例如:warning:libb.so needed by liba.so not found.原因是:例如代码引用了liba.so,但是liba.so又引用了libb.so,这种情况是由于makefile没有显示指定需要链接b.so,
解决这个问题目前有三种方法:1:在makefile里面显示链接-lb,2:可以增加rpath参数,指定libb.so的路径3:可以将libb.so的路径加入系统链接路径/etc/ld.so.conf。

关于-Wl参数说明:
-Wl,option
           Pass option as an option to the linker.  If option contains commas,
           it is split into multiple options at the commas.  You can use this
           syntax to pass an argument to the option.  For example,
           -Wl,-Map,output.map passes -Map output.map to the linker.  When using
           the GNU linker, you can also get the same effect with
           -Wl,-Map=output.map.

           NOTE: In Ubuntu 8.10 and later versions, for LDFLAGS, the option
           -Wl,-z,relro is used.  To disable, use -Wl,-z,norelro.
-Wl,-rpath=《your_lib_dir》
-Wl
这个是gcc的参数,表示编译器将后面的参数传递给链接器ld。
又比如gcc编译怎样指定特定的链接器?(未验证)
-Wl,--dynamic-linker=/path/lib/ld-linux-x86-64.so.2


-rpath
使用man ld命令查看手册,找到了-rpath的讲解:
 Add a directory to the runtime library search path. This is used when linking an ELF executable with shared objects. All -rpath arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime. The -rpath option is also used when locating shared objects which are needed by shared objects explicitly included in the link; see the description of the -rpath-link option. If -rpath is not used when linking an ELF executable, the contents of the environment variable "LD_RUN_PATH" will be used if it is defined.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值