/ usr / bin / ld:找不到共享库 [英] /usr/bin/ld: cannot find shared library

查看:336
本文介绍了/ usr / bin / ld:找不到共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




gcc在/ usr / local / lib中我有libcommon.so, -o test test_prog.c -L / usr / local / lib -llibcommon.so

我也试过这个


gcc -o test test_prog.c -L / usr / local / lib -llibcommon

给出的是


/ usr / bin / ld:找不到-llibcommon.so

collect2:ld返回1退出状态

它在那里:

  $ locate libcommon.so 
/usr/local/lib/libcommon.so
/usr/local/lib/libcommon.so.0
/usr/local/lib/libcommon.so.0.1.0
$


解决当您使用 -l <​​/ code>时,只需指定'basic'库名称:

  -lcommon 

这将追踪 libcommon.so in某些目录。

您告诉编译器尝试找到 liblibcommon.so.so (和 liblibcommon.so ),它可能不会......实际上,你不会问这个问题是否可以。



一些GNU程序构建一个库 libiberty.so (或其等价物),所以使用库的链接链接:

  -liberty 

GNU真的宁愿它是 + liberty ,但是......你无法修复所有的东西)。




I am having libcommon.so in the /usr/local/lib and I am linking this library in my program.

gcc -o test test_prog.c -L/usr/local/lib -llibcommon.so

and I have tried this too

gcc -o test test_prog.c -L/usr/local/lib -llibcommon

It's giving

/usr/bin/ld: cannot find -llibcommon.so
collect2: ld returned 1 exit status

It is there:

$ locate libcommon.so
/usr/local/lib/libcommon.so
/usr/local/lib/libcommon.so.0
/usr/local/lib/libcommon.so.0.1.0
$

解决方案

When you use the -l, you specify just the 'basic' library name:

-lcommon

This will track down libcommon.so in some directory.

You told the compiler to try and find liblibcommon.so.so (and liblibcommon.so) and it probably couldn't...indeed, you wouldn't be asking the question if it could.

Some GNU programs build a library libiberty.so (or its equivalent), so the link lines using the library link with:

-liberty

(which is funny; GNU would really rather it was +liberty, but ... you can't fix everything).

这篇关于/ usr / bin / ld:找不到共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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