LINK_LIBRARIES: Targets may link only to libraries. CMake is dropping the item.
来源:互联网 发布:python与自然语言处理 编辑:程序博客网 时间:2024/06/15 11:42
编译项目时,用到external library (matlab,需要用到它的libeng.so和libmx.so库),CMakeLists.txt中有这么一句:
LINK_LIBRARIES("/opt/MATLAB/R2012a/bin/glnxa64")
编译时会报如下警告和错误:
改后再试,警告消失,成功编译完。
LINK_LIBRARIES的使用和link_directories比较类似,这里也可以简单的替换上面2行为:
link_directories("/opt/MATLAB/R2012a/bin/glnxa64")
同样的作用。我在这里总结了link_directories, LINK_LIBRARIES和target_link_libraries的区别和使用小结。
参考:
http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=12618
https://groups.google.com/forum/#!msg/ceres-solver/Y2mV-vKXsZE/2FinShKM2PsJ
LINK_LIBRARIES("/opt/MATLAB/R2012a/bin/glnxa64")
编译时会报如下警告和错误:
$ sudo make-- Configuring doneWARNING: Target "myProject" requests linking to directory "/opt/MATLAB/R2012a/bin/glnxa64". Targets may link only to libraries. CMake is dropping the item.-- Generating done-- Build files have been written to: /opt/matlabEngine_example3_cmakeLinking CXX executable myProject/usr/bin/ld: cannot find -leng/usr/bin/ld: cannot find -lmxcollect2: ld returned 1 exit statusmake[2]: *** [myProject] Error 1make[1]: *** [CMakeFiles/myProject.dir/all] Error 2make: *** [all] Error 2错误提示很显然,找不到libeng.so和libmx.so库。搜索一下它们所在路径,就是在/opt/MATLAB/R2012a/bin/glnxa64目录下:
$ locate libeng.so/opt/MATLAB/MATLAB_Compiler_Runtime/v717/bin/glnxa64/libeng.so/opt/MATLAB/R2012a/bin/glnxa64/libeng.so$ locate libmx.so/opt/MATLAB/MATLAB_Compiler_Runtime/v717/bin/glnxa64/libmx.so/opt/MATLAB/R2012a/bin/glnxa64/libmx.so
原来LINK_LIBRARIES是需要指明到具体的库文件名字(You need to specify the full path to the .so files)。这样写就可以了:
LINK_LIBRARIES("/opt/MATLAB/R2012a/bin/glnxa64/libeng.so")LINK_LIBRARIES("/opt/MATLAB/R2012a/bin/glnxa64/libmx.so")
改后再试,警告消失,成功编译完。
$ sudo make-- Configuring done-- Generating done-- Build files have been written to: /opt/matlabEngine_example3_cmakeLinking CXX executable myProject[100%] Built target myProject
LINK_LIBRARIES的使用和link_directories比较类似,这里也可以简单的替换上面2行为:
link_directories("/opt/MATLAB/R2012a/bin/glnxa64")
同样的作用。我在这里总结了link_directories, LINK_LIBRARIES和target_link_libraries的区别和使用小结。
参考:
http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=12618
https://groups.google.com/forum/#!msg/ceres-solver/Y2mV-vKXsZE/2FinShKM2PsJ
0 0
- LINK_LIBRARIES: Targets may link only to libraries. CMake is dropping the item.
- Targets may link only to libraries. CMake is dropping the item.
- a pointer to a bound function may only be used to call the function
- a pointer to a bound function may only be used to call the function
- error target id is not valid use android list targets to get the target ids
- ReactNative警告:bind(): React component methods may only be bound to the component instance
- Warning: bind(): React component methods may only be bound to the component instance. See ...
- Linker and Libraries Guide Chapter 1 Introduction to the Solaris OS Link Editors
- cmake 解决错误:Cannot specify link libraries for target
- CMake link_directories, LINK_LIBRARIES, target_link_libraries使用总结
- 编译报错“a pointer to a bound function may only be used to call the function”的解决办法
- Ubutun 编译完sdk 出现Target id is not valid. Use 'android list targets' to get the target ids.
- Error: Target id 'android--1' is not valid. Use 'android.bat list targets' to get the target ids.
- Linq To xRM Issue(CRM 4.0 Online): The 'select' and 'orderBy' calls may only reference a single common entity type.
- How to solve “add/remove operation is impossible, because the code element 'Cxxx' is read only”
- Access to the requested object is only available from the local network phpmyadmin
- New XAMPP security concept: Access to the requested object is only available from the local network
- Only the Kotlin standard library is allowed to use the 'kotlin' package
- hdu 1501 简单dp (最长公共子串的变形)
- HDU 1098 Ignatius's puzzle
- How do I fix Passenger application startup problem
- 墓地雕像
- 好记性不如烂笔头25-JAVA处理数据库事务(3) - 事务回滚点
- LINK_LIBRARIES: Targets may link only to libraries. CMake is dropping the item.
- 四种生成和解析XML文档的方法详解(介绍+优缺点比较+示例)
- bzoj 1047 题解
- iOS UI 的坑:不要 remove UITableViewCell 的 contentView
- guice入门学习与实例一
- Java中 Timer缺陷,用ScheduledExecutorService替代
- virtualbox虚拟机安装Mac OS 10.6.x全过程
- set_new_handler
- [Swift 开发] swift支持多线程操作数据库类库-CoreDataManager