当前位置:网站首页>ROS编译 调用第三方动态库(xxx.so)
ROS编译 调用第三方动态库(xxx.so)
2022-07-06 08:22:00 【Will_Ye】
1. Problem
在做项目过程中,不可避免,有时需要使用一些第三方的开源库,或者自己写的动态库,然后就需要CMakeLists中添加这些动态库对应的路径,进行编译。
需要调用的动态库后缀一般为.so
,有时也会遇到除了libxxx.so
,还有libxxx.so.x
和libxxx.so.x.y.z
这些,如libzzz.so
,还有libzzz.so.1
和libzzz.so.1.0.0
在后缀.so
后的这些数字,其实代表的是不同版本,用来做版本管理的,所以整个动态库的文件名是有讲究的。比如libzzz.so.1.2.3
,lib是固定代表共享库,zzz是共享库名称,.so是固定后缀,1表示的是主版本号,2表示次版本号,3表示发行版本号。
主版本号:不同的版本号之间不兼容
次版本号:增量升级,向后兼容
发行版本号:对应次版本的错误修正和性能提升,不影响兼容性
而且这个名字最长的libxxx.so.x.y.z
,是实际的库文件,含有的是可执行的二进制代码。所以就可以用指令readelf -d libzzz.so.1.2.3
去读这个文件。
其实生成库的时候,也可以直接只生成一个libzzz.so
作为实际库文件,这个看个人了,标准一点是应该做好库版本管理的。
2. Method
在ROS的package中,一般都会建立两个文件夹 (include和lib),存放.h
的头文件和.so
的动态库文件,所以,我们只要把第三方的动态库文件放进lib
文件夹中,不要忘了把相关的libxxx.so.x
和libxxx.so.x.y.z
也一并放进去,少了谁都不行。
动态库文件放好后,修改一下CMakeList就可以了
cmake_minimum_required(VERSION 2.8.3)
SET(CMAKE_BUILD_TYPE Debug)
add_compile_options( -std=c++11)
project(gazebo_mobile_manipulator)
find_package(PCL 1.8 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(catkin REQUIRED COMPONENTS
nav_msgs
roscpp
rospy
serial
tf
std_msgs
std_srvs
actionlib
actionlib_msgs
message_generation
geometry_msgs
pcl_conversions
pcl_ros
PCL
)
catkin_package(
CATKIN_DEPENDS roscpp rospy serial std_msgs message_runtime
INCLUDE_DIRS include
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
link_directories(
${catkin_LIB_DIRS} lib
)
add_executable(test src/test1.cpp)
target_link_libraries(test ${PCL_LIBRARIES} ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} libzzz.so)
注意最后一行,在target_link_libraries
里面,只需要添加libzzz.so
就可以了,不需要把后面带版本号的也加进去,通过.so这个就会搜索到其他的。
然后catkin_make编译就可以了
边栏推荐
- [research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached
- JS select all and tab bar switching, simple comments
- VMware 虚拟化集群
- Permutation and combination function
- 【MySQL】日志
- 从 CSV 文件迁移数据到 TiDB
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
- [cloud native] teach you how to build ferry open source work order system
- CAD ARX 获取当前的视口设置
猜你喜欢
"Designer universe" APEC design +: the list of winners of the Paris Design Award in France was recently announced. The winners of "Changsha world center Damei mansion" were awarded by the national eco
2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers
Make learning pointer easier (3)
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
Understanding of law of large numbers and central limit theorem
Asia Pacific Financial Media | female pattern ladyvision: forced the hotel to upgrade security. The drunk woman died in the guest room, and the hotel was sentenced not to pay compensation | APEC secur
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
[cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes
化不掉的钟薛高,逃不出网红产品的生命周期
Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
随机推荐
[research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached
Use br to back up tidb cluster data to S3 compatible storage
Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
Asia Pacific Financial Media | designer universe | Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers
hcip--mpls
The Vice Minister of the Ministry of industry and information technology of "APEC industry +" of the national economic and information technology center led a team to Sichuan to investigate the operat
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
远程存储访问授权
[secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
Migrate data from a tidb cluster to another tidb cluster
C language - bit segment
Wincc7.5 download and installation tutorial (win10 system)
【云原生】手把手教你搭建ferry开源工单系统
使用 BR 备份 TiDB 集群数据到兼容 S3 的存储
从表中名称映射关系修改视频名称
JS select all and tab bar switching, simple comments
Deep learning: derivation of shallow neural networks and deep neural networks
Yyds dry goods inventory three JS source code interpretation eventdispatcher
Asia Pacific Financial Media | "APEC industry +" Western Silicon Valley invests 2trillion yuan in Chengdu Chongqing economic circle to catch up with Shanghai | stable strategy industry fund observatio
Analysis of pointer and array written test questions