0
$\begingroup$

Rosanswers logo

Example ;

find_package(RTABMap 0.19.5 REQUIRED)

find_package(OpenCV 4.2.0 REQUIRED)

find_package(PCL 1.7 REQUIRED)
add_definitions(${PCL_DEFINITIONS}) # To include -march=native if set

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES rtabmap_ros
  CATKIN_DEPENDS cv_bridge roscpp rospy sensor_msgs std_msgs std_srvs nav_msgs geometry_msgs visualization_msgs
                 image_transport tf tf_conversions tf2_ros eigen_conversions laser_geometry pcl_conversions 
                 pcl_ros nodelet dynamic_reconfigure message_filters class_loader rosgraph_msgs
                 stereo_msgs move_base_msgs image_geometry ${optional_dependencies}
  DEPENDS RTABMap OpenCV
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  ${RTABMap_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  ${PCL_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)

# libraries
SET(Libraries
   ${OpenCV_LIBRARIES}
   ${PCL_LIBRARIES}
   ${catkin_LIBRARIES}
   ${RTABMap_LIBRARIES}
)

It works like this when compiled.

I just changed the find_package () section.

Is it necessary to make changes in other parts? For Example in catkin_package ().

catkin_package ( DEPENDS RTABMap OpenCV )

to

catkin_package ( DEPENDS RTABMap OpenCV 4.2.0 )

Thanks in advance.


Originally posted by jahim44229 on ROS Answers with karma: 20 on 2020-03-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

find_package(OpenCV 4.2.0 REQUIRED) is enough. You dont need to specify the version later on I think.
Check the following question. It gives a good explanation on how to use CMake macros.

Also dont forget to link the libraries:

target_link_libraries(your_executable
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)

Originally posted by pavel92 with karma: 1655 on 2020-03-09

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.