gpt4 book ai didi

c -/usr/bin/ld : cannot find shared library

转载 作者:太空宇宙 更新时间:2023-11-04 05:19:26 25 4
gpt4 key购买 nike

我在/usr/local/lib 中有 libcommon.so,我正在我的程序中链接这个库。

gcc -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: cannot find -llibcommon.so
collect2: ld returned 1 exit status

它在那里:

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

最佳答案

当您使用 -l 时,您只需指定“基本”库名称:

-lcommon

这将在某个目录中找到 libcommon.so

您告诉编译器尝试查找 liblibcommon.so.so(和 liblibcommon.so),但它可能找不到……事实上,您不会如果可以,请不要问这个问题。

一些 GNU 程序构建了一个库 libiberty.so(或其等价物),因此使用该库的链接行链接到:

-liberty

(这很有趣;GNU 真的更希望它是 +liberty,但是……你不能解决所有问题)。

关于c -/usr/bin/ld : cannot find shared library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18639723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com