c++ - ld 找不到可用的库

标签 c++ makefile ld

我在链接我的应用程序时遇到问题,ld 找不到可用的库:

/usr/bin/ld : could not find -lVtsUtils_0.1.5d
/usr/bin/ld : could not find -lVtsCore_0.1.5d
/usr/bin/ld : could not find -llibmysql

编译行是(通过make VERBOSE=1找到):

/usr/bin/c++ -g CMakeFiles/Dental.dir/main.cpp.o CMakeFiles/Dental.dir/qrc_myproject.cpp.o CMakeFiles/Dental.dir/Dental_automoc.cpp.o -o ../../../bin/debug/Dentald -L/home/naccyde/Projets/myproject/lib/linux -rdynamic /usr/lib64/libQt5Widgets.so.5.6.2 -lVtsUtils_0.1.5d -lVtsCore_0.1.5d -llibmysql /usr/lib64/libQt5Gui.so.5.6.2 /usr/lib64/libQt5Core.so.5.6.2 -Wl,-rpath,/home/naccyde/Projets/myproject/lib/linux

但是 ls -l/home/naccyde/Projets/myproject/lib/linux 显示:

-rwxrwxrwx. 1 naccyde naccyde  2067984  2 mars  17:34 VtsCore_0.1.5d.so
-rwxrwxrwx. 1 naccyde naccyde 10984568  2 mars  17:34 VtsNavigation_0.1.5d.so
-rwxrwxrwx. 1 naccyde naccyde  4760776  2 mars  17:34 VtsUtils_0.1.5d.so

我不明白为什么它不起作用。

最佳答案

Linux(或所有 POSIX 系统)上的库需要以 lib 为前缀。因此,名为 VtsCore_0.1.5d 的动态库的文件名应为 libVtsCore_0.1.5d.so

适本地重命名您的库。或者将实际库文件的完整路径(例如 /home/naccyde/Projets/myproject/lib/linux/VtsCore_0.1.5d.so)传递给链接器。

关于c++ - ld 找不到可用的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42561501/

相关文章:

c++ - 如果使用函数 relace1() 不删除由 cc 分配的内存,此代码是否会泄漏?

c - Makefile: '_start'的多重定义

c++ - 将文本写入二进制文件 - 有什么区别?

c++ - 将 Unicode 字符串作为字符循环

python - pylucene安装makefile报错

makefile - CMake 如何检测更改的文件

c - 用函数 B 覆盖弱函数 A

c - 使用 objdump/readelf 和 extern 变量

linux - 如何强制链接来自特定库的符号?

c++ - 套接字应用程序无法在 Internet 上运行