Linux下ld搜索问题:ld: cannot find -l"XX"

ld命令行工具(链接库的一个工具)的搜索路径是-L指定的,库名是-l指定的。

 

比如: ld -L[dir] -l[mylib] --verbose

以上我用可视化的方法显示ld的搜索路径,其结果是居然在mylib,也就是库文件名中自动加入了前缀lib,导致找不到我的mylib,因为我的lib名字没有加入lib的前缀。所以要把库名改了,加上lib前缀。我操,ld这样的设计目的是什么?加入前缀是为了减少冲突概率么???类似很多第三方库的API也是有自己的前缀,比如openGL就有gl的前缀,就是为了减少冲突。

 

ld -L/home/a/dls/dls/trunk/dlf/pc/lib -lkp_wdapi1160_gcc_v3 --verbose

attempt to open /home/a/dls/dls/trunk/dlf/pc/lib/libkp_wdapi1160_gcc_v3.so failed
attempt to open /home/a/dls/dls/trunk/dlf/pc/lib/libkp_wdapi1160_gcc_v3.a failed
attempt to open /usr/x86_64-linux-gnu/lib64/libkp_wdapi1160_gcc_v3.so failed
attempt to open /usr/x86_64-linux-gnu/lib64/libkp_wdapi1160_gcc_v3.a failed
attempt to open /usr/local/lib/x86_64-linux-gnu/libkp_wdapi1160_gcc_v3.so failed
attempt to open /usr/local/lib/x86_64-linux-gnu/libkp_wdapi1160_gcc_v3.a failed
attempt to open /usr/local/lib64/libkp_wdapi1160_gcc_v3.so failed
attempt to open /usr/local/lib64/libkp_wdapi1160_gcc_v3.a failed
attempt to open /lib/x86_64-linux-gnu/libkp_wdapi1160_gcc_v3.so failed
attempt to open /lib/x86_64-linux-gnu/libkp_wdapi1160_gcc_v3.a failed
attempt to open /lib64/libkp_wdapi1160_gcc_v3.so failed
attempt to open /lib64/libkp_wdapi1160_gcc_v3.a failed
attempt to open /usr/lib/x86_64-linux-gnu/libkp_wdapi1160_gcc_v3.so failed
attempt to open /usr/lib/x86_64-linux-gnu/libkp_wdapi1160_gcc_v3.a failed
attempt to open /usr/lib64/libkp_wdapi1160_gcc_v3.so failed
attempt to open /usr/lib64/libkp_wdapi1160_gcc_v3.a failed
attempt to open /usr/local/lib/libkp_wdapi1160_gcc_v3.so failed
attempt to open /usr/local/lib/libkp_wdapi1160_gcc_v3.a failed
attempt to open /lib/libkp_wdapi1160_gcc_v3.so failed
attempt to open /lib/libkp_wdapi1160_gcc_v3.a failed
attempt to open /usr/lib/libkp_wdapi1160_gcc_v3.so failed
attempt to open /usr/lib/libkp_wdapi1160_gcc_v3.a failed
ld: cannot find -lkp_wdapi1160_gcc_v3

 

 

reference:

http://stackoverflow.com/questions/16710047/usr-bin-ld-cannot-find-lnameofthelibrary

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。