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