大量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.

你可能感兴趣的:(大量warning:libb.so needed by liba.so not found.的问题解决方法)