平台:ubuntu22.04
我正在使用cmake链接到第三方库。它看起来像:
// Those two files are identical.
// abc.so is the original file and libabc.so is a copy
// ${shared} is an absolute path
${shared}/libabc.so
${shared}/abc.so
我的CMakeLists.txt:
LINK_DIRECTORIES(${shared})
ADD_EXECUTABLE(main ...)
TARGET_LINK_LIBRARIES(main libabc.so)
到目前为止,它运行良好。你可能已经注意到我
${shared}/libabc.so
和
${shared}/abc.so
同时它们完全相同。所以我删除了libabc.So(abc.So是原始文件),并创建了一个链接文件
ln -s relative_path/shared/abc.so relative_path/shared/libabc.so
.
但我得到了:
/usr/bin/ld: cannot find -labc: No such file or directory
collect2: error: ld returned 1 exit status
当libabc.so确实存在时,为什么我会得到这个错误?