Ask Your Question

Absolute and Relative paths

asked 2020-01-13 11:42:58 -0500

mikepark93 gravatar image

I get the following error when trying to generate ros2 interfaces.

[build] CMake Error at /opt/ros/dashing/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:80 (message):
[build]   rosidl_generate_interfaces() the passed absolute file
[build]   '/ros2_msgs/srv/Connect' must be represented as an absolute base path
[build]   separated by a colon from the relative path to the interface file
[build] Call Stack (most recent call first):
[build]   CMakeLists.txt:67 (rosidl_generate_interfaces)
edit retag flag offensive close merge delete


You need to share your CMake code for people to be able to help you.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-01-13 12:17:37 -0500 )edit

Apologies. Here is the CMake file.

cmake_minimum_required(VERSION 3.14)

SET(ENV{PYTHONPATH} "/opt/ros/dashing/lib/python3.6/site-packages/")
SET(CMAKE_PREFIX_PATH "/opt/ros/dashing")

find_package(rosidl_default_generators REQUIRED)


Reason for setting the prefix path and the python path is because I am trying to build without using colcon,

mikepark93 gravatar image mikepark93  ( 2020-01-13 12:23:15 -0500 )edit

The prefix path (CMAKE_PREFIX_PATH) has nothing to do with the error message. But you shouldn't put that into your CMakeLists.txt but instead set it in the environment before building your package - otherwise you can't build your package with other ROS distros - or in combination with a from-source build on other platforms.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-01-13 12:29:09 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-01-13 12:27:37 -0500

Dirk Thomas gravatar image

You don't need to pass an absolute path to rosidl_generator_interfaces(). A relative path will be just fine, so removing ${CMAKE_CURRENT_SOURCE_DIR}/ should be all it takes.

It also seems that your service file lacks the extension .srv.

The alternative would be to pass an absolute base path (${CMAKE_CURRENT_SOURCE_DIR}) and the relative path (srv/Connect.srv) - separated by a colon.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-01-13 11:42:58 -0500

Seen: 581 times

Last updated: Jan 13 '20