Platform: ubuntu22.04 I'm using cmake to link to a 3rd party library. It looks like:
// 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
My CMakeLists.txt:
LINK_DIRECTORIES(${shared})
ADD_EXECUTABLE(main ...)
TARGET_LINK_LIBRARIES(main libabc.so)
So far it works fine. You may have noticed that I have ${shared}/libabc.so
and ${shared}/abc.so
at the same time. They are identical. So I delete libabc.so (abc.so is the original file) and create a link file with
ln -s relative_path/shared/abc.so relative_path/shared/libabc.so
.
But I got:
/usr/bin/ld: cannot find -labc: No such file or directory
collect2: error: ld returned 1 exit status
Why do I get this error when libabc.so did exists?
abc.so
,abc
,libabc.so
,libabc
.ln -s
path should be absolute. My ${shared} is absolute path. I didn't make that clear.${share}
is. The issue was aboutln
notlink_diretories
. It works before I useln
.${shared}
is? Now I'm just very confused.