# How to add an external package to my node ROS2

Ubuntu 18.04 ros2 Dasing C++

Hi, I don't understand well where my CMakeLists get the packages, but it takes the ones installed when I installed ROS2 (std_msgs, sensor_msgs, rclcpp...), now I want to get a package from another directory, in this case I want to find armadillo.

I think this have to be easy, but I dont figure out how to do it.

When I try to look for armadillo with find_package(armadillo REQUIRED) in the CMakeLists.txt an error jump to my terminal:

CMake Error at CMakeLists.txt:18 (find_package): By not providing "Findarmadillo.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by
"armadillo", but CMake did not find one.

Could not find a package configuration file provided by "armadillo" with any of the following names:

armadilloConfig.cmake


Add the installation prefix of "armadillo" to CMAKE_PREFIX_PATH or set "armadillo_DIR" to a directory containing one of the above files. If "armadillo" provides a separate development package or SDK, be sure it has been installed.

I tried several things in touching the CMakeLists.txt but no one works, I added this in the package.xml too:

  <build_depend>armadillo</build_depend>


And this is what I have about armadillo in my CMakeLists.txt at the moment:

find_package(armadillo REQUIRED)

ament_target_dependencies(editer
"rclcpp"
"std_msgs"
"opencv2"
"sensor_msgs"
"cv_bridge"
)


Maybe is not necessary, but I post it can be usefull

edit retag close merge delete

Sort by » oldest newest most voted

target_link_libraries(editer ${ARMADILLO_LIBRARIES})  too, to works, so finally it works with: find_package(Armadillo REQUIRED) add_executable(editer src/imagediter.cpp ) target_link_libraries(editer${ARMADILLO_LIBRARIES})
ament_target_dependencies(editer
"rclcpp"
"std_msgs"
"opencv2"
"sensor_msgs"
"cv_bridge"
)


Don't know if all packages works in the same way, so I let this for other people having the same problems, remember to check your package cmake here: https://cmake.org/cmake/help/v3.0/ind...

more

Don't know if this is relative to ROS2 or to CMake, is true that the problem and solution cames from CMake, but colcon build uses cmake and I found this problem using ROS2, so im confused about if post this things here or not, or where to ask then

( 2020-02-21 09:09:34 -0500 )edit

that's fair enough it's not necessarily evident what is CMake related and what comes from ROS code :+1:

( 2020-02-21 19:10:38 -0500 )edit

This is a pure CMake question unrelated to ROS. I encourage you to search on other fora for this kind of non-ROS question in the future.

In this case the name of the library is Armadillo and CMake is case sensitive. to find it you need to:

find_package(Armadillo REQUIRED)


Example on the official CMake documentation: https://cmake.org/cmake/help/v3.0/mod...

more

Ops, seems that was te reason, but I still have errors trying to compile my executable... reference to 'wrapper2_dgemv_ 'undefined and one warning that I can not fix:

 is deprecated: publishing an unique_ptr is prefered when using intra process communication. If using a shared_ptr, use publish(*msg). [-Wdeprecated-declarations]


I'm new in this forum, isn't here where I can answer about my colcon build results? where I should ask then? thanks

( 2020-02-21 06:37:04 -0500 )edit

I'm new in this forum, isn't here where I can answer about my colcon build results? where I should ask then? Yes this is the right venue for ROS questions. My remark was because your original question was about how to find a non-ROS library in CMake so it was not a "ROS question"

but I still have errors trying to compile my executable...

This looks like a different question. Could you please open a new question with the full error messages? as well as information and code to provide enough context for people to help you find the issue. You can see this wiki page for guidelines for asking questions.

Ops, seems that was te reason

Please consider accepting the answer above (by clicking the checkmark on the left) if it solved your original question

( 2020-02-21 06:49:41 -0500 )edit

mmm, I was considering it, but I'm not still sure if that fixed my problem, because in the theory the next error appears when it doesn't find the package... So I don't know if the package has been added correctly to my node.

Don't know if I should edit my question or open a new one. If I open a new one, and fix the problem then I can see if this works correctly, and then check as solution.

( 2020-02-21 08:35:31 -0500 )edit

I can't mark my own answer as solution because I need a kind of points (this is not a game, just a forum to find solutions to a problem relative to ROS, I don't care about points), if you want, publish an answer or edit this one adding the

target_link_libraries(editer \${ARMADILLO_LIBRARIES})


And I chek as solution :D

( 2020-02-21 09:16:01 -0500 )edit

( 2020-02-21 19:11:14 -0500 )edit