当前位置:网站首页>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编译就可以了
边栏推荐
- VMware virtualization cluster
- Résumé des diagrammes de description des broches de la série ESP
- 在 uniapp 中使用阿里图标
- [research materials] 2021 China online high growth white paper - Download attached
- Migrate data from CSV files to tidb
- IoT -- 解读物联网四层架构
- The resources of underground pipe holes are tight, and the air blowing micro cable is not fragrant?
- Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
- The State Economic Information Center "APEC industry +" Western Silicon Valley will invest 2trillion yuan in Chengdu Chongqing economic circle, which will surpass the observation of Shanghai | stable
- logback1.3. X configuration details and Practice
猜你喜欢
Leetcode question brushing record | 203_ Remove linked list elements
Learn Arduino with examples
[research materials] 2021 China online high growth white paper - Download attached
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
IOT -- interpreting the four tier architecture of the Internet of things
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
[research materials] 2022 enterprise wechat Ecosystem Research Report - Download attached
"Designer universe": "benefit dimension" APEC public welfare + 2022 the latest slogan and the new platform will be launched soon | Asia Pacific Financial Media
2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers
随机推荐
Restore backup data on S3 compatible storage with tidb lightning
化不掉的钟薛高,逃不出网红产品的生命周期
Permutation and combination function
Deep learning: derivation of shallow neural networks and deep neural networks
指针和数组笔试题解析
2022.02.13 - NC001. Reverse linked list
Hill sort c language
vulnhub hackme: 1
From monomer structure to microservice architecture, introduction to microservices
Leetcode question brushing (5.31) string
Grayscale upgrade tidb operator
[MySQL] lock
【云原生】手把手教你搭建ferry开源工单系统
Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation
[cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes
synchronized 解决共享带来的问题
Upgrade tidb with tiup
Leetcode skimming (5.29) hash table
Analysis of Top1 accuracy and top5 accuracy examples
2022.02.13 - NC003. Design LRU cache structure