[英]Cmake cannot find library
I have a library called Kinova.API.CommLayerUbuntu.so
which I want to link against with cmake. 我有一个名为
Kinova.API.CommLayerUbuntu.so
的库,我想与cmake链接。 So, in my CMakeLists.txt
file, I have the line: 因此,在我的
CMakeLists.txt
文件中,我这一行:
target_link_libraries(demo ~/Libraries/Kinova.API.CommLayerUbuntu.so)
However, during compilation, I receive the error: 但是,在编译期间,我收到错误消息:
cannot find -lKinova.API.CommLayerUbuntu
This baffles me because I am telling cmake to look for Kinova.API.CommLayerUbuntu.so
, not for -lKinova.API.CommLayerUbuntu
. 这让我感到
Kinova.API.CommLayerUbuntu.so
,因为我告诉cmake寻找Kinova.API.CommLayerUbuntu.so
而不是-lKinova.API.CommLayerUbuntu
。 Please could somebody explain what is going on? 请有人可以解释发生了什么吗?
In verbose mode, the cmake output gives the following: 在详细模式下,cmake输出给出以下内容:
Linking CXX executable demo
/usr/bin/cmake -E cmake_link_script CMakeFiles/demo.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/demo.dir/demo.cpp.o -o demo -L/home/karnivaurus/Libraries -rdynamic -lKinova.API.CommLayerUbuntu -Wl,-rpath,/home/karnivaurus/Libraries
/usr/bin/ld: cannot find -lKinova.API.CommLayerUbuntu
The -l
is just the flag used to tell the compiler to link a library. -l
只是用于告诉编译器链接库的标志。 Your library name is nonstandard. 您的库名称是非标准的。 The compiler will remove the
-l
and prepend lib
to the string you use, and look for a file called libKinova.API.CommLayerUbuntu.so
. 编译器将删除
-l
并将lib
放在您使用的字符串前面,并查找名为libKinova.API.CommLayerUbuntu.so
的文件。
This looks like an issue with the distribution of this API. 这似乎与该API的发行有关。 You can try working around it by creating a symbolic link from
libKinova.API.CommLayerUbuntu.so
to Kinova.API.CommLayerUbuntu.so
. 您可以尝试通过创建从
libKinova.API.CommLayerUbuntu.so
到Kinova.API.CommLayerUbuntu.so
的符号链接来libKinova.API.CommLayerUbuntu.so
此Kinova.API.CommLayerUbuntu.so
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.