ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to compile C++ library inside ROS package?

asked 2020-04-22 20:27:05 -0500

Ralff gravatar image

updated 2022-01-22 16:16:19 -0500

Evgeny gravatar image

I have a package structured as follows:

-include
-src
-my_submodule
  -include
  -src
  CMakeLists.txt
CMakeLists.txt
package.xml

The my_submodule folder is basically a C++ library that I want to compile along with my ROS package and use as a dependency. I could install my_submodule and use find_package(my_submodule), but I want to compile my_submodule along with the package.

What do I need to modify to compile my_submodule along with my package? The idea is that my_submodule is not dependent on ROS or my package, but I want to include without installing separately.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-04-22 21:59:35 -0500

updated 2020-04-22 21:59:54 -0500

This doesn't seem like a ROS question but a CMake question. For example: regardless of ROS, are you aware of how to link up multiple cmakelists together?

A good hint is looking at the add_subdirectory() macro in CMake.

Examples:

https://github.com/ros-planning/navig...

https://github.com/SteveMacenski/slam...

edit flag offensive delete link more

Comments

Yes. I use add_subdirectory(), but the subdirectory is not compiling. The command doesn't seem like it is doing anything.

Ralff gravatar image Ralff  ( 2020-04-22 22:42:43 -0500 )edit
1

Without far more information, there's no help anyone can give. Please edit your original question with more detail.

stevemacenski gravatar image stevemacenski  ( 2020-04-22 22:48:32 -0500 )edit

add_subdirectory() did work. I changed the build directory, and I was checking wrong directory to see if worked properly... Thank you for your answer!

Ralff gravatar image Ralff  ( 2020-04-23 12:28:02 -0500 )edit

No worries! Can you mark the question as correct so its off the unanswered questions queue?

stevemacenski gravatar image stevemacenski  ( 2020-04-23 15:03:45 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-04-22 20:27:05 -0500

Seen: 679 times

Last updated: Apr 22 '20