fatal error: rclcpp/rclcpp.hpp: No such file or directory

asked 2020-02-13 03:17:06 -0600

snvk gravatar image

updated 2020-02-13 10:01:06 -0600

Hi, even after sourcing and all the path is included correctly, I get this error while I try to compile (few other projects compiles well from the same workspace directory that which includes rclcpp.hpp ) version-dashing on 18.04

/home/snvk/ros2_dashing/src/ros2_fr/src/fr_subscriber.cpp:2:10: fatal error: rclcpp/rclcpp.hpp: No such file or directory
 include "rclcpp/rclcpp.hpp"

compilation terminated.

gmake[2]: *** [CMakeFiles/subscriber.dir/src/fr_subscriber.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/subscriber.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
gmake: *** [all] Error 2

Failed   <<< ros2_fr    [ Exited with code 2 ]
Summary: 0 packages finished [3.39s]
  1 package failed: ros2_fr

  1 package had stderr output: ros2_fr

Thanks in advance

edit retag flag offensive close merge delete

Comments

Could you show your CMakeLists.txt? Please remove all the boilerplate comments from it (lines starting with #) before you post it.

gvdhoorn gravatar imagegvdhoorn ( 2020-02-13 03:55:48 -0600 )edit
cmake_minimum_required(VERSION 3.5)
project(fr_ros2)

if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(fr_msgs REQUIRED)
find_package(std_msgs REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

add_executable(publisher_fr src/fr_publisher.cpp)
ament_target_dependencies(publisher_fr rclcpp fr_msgs std_msgs)

install(TARGETS
publisher_fr
DESTINATION lib/${PROJECT_NAME}
)

ament_package()

enter code here
snvk gravatar imagesnvk ( 2020-02-13 10:06:32 -0600 )edit

I don't see a problem with the CMakeLists.txt. Can you provide your package.xml as well?

Carl D gravatar imageCarl D ( 2020-02-13 11:42:23 -0600 )edit
<package format="3">
  <name>frgen_ros2</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="snvk@gmail.com">snvk</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>rclcpp</depend>
  <depend>frgen_msgs</depend>
  <depend>std_msgs</depend>

  <build_depend>rosidl_default_generators</build_depend>
  <exec_depend>builtin_interfaces</exec_depend>
  <exec_depend>rosidl_default_runtime</exec_depend>
  <member_of_group>rosidl_interface_packages</member_of_group>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

enter code here
snvk gravatar imagesnvk ( 2020-02-14 02:19:31 -0600 )edit

The package.xml looks ok as well. But I just noticed that your compile error is for fr_subscriber.cpp. That isn't in your CMakeLists.txt. It only contains fr_publisher.cpp. Did you provide the wrong CMakeLists.txt? How does the fr_subscriber file get built?

Carl D gravatar imageCarl D ( 2020-02-14 02:59:56 -0600 )edit

Hi, Yes! sorry I just provided you the wrong

cmake_minimum_required(VERSION 3.5)
project(fr_ros2)

if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 99) endif()

if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif()

find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(fr_msgs REQUIRED) find_package(std_msgs REQUIRED)

if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() endif()

add_executable(publisher_fr src/fr_publisher.cpp) ament_target_dependencies(publisher_fr rclcpp fr_msgs std_msgs) install(TARGETS publisher_fr DESTINATION lib/${PROJECT_NAME} )

add_executable(subscriber_fr src/fr_subscriber.cpp) ament_target_dependencies(subscriber_fr rclcpp fr_msgs std_msgs) install(TARGETS subscriber_fr DESTINATION lib/${PROJECT_NAME} ) ament_package() enter code here

snvk gravatar imagesnvk ( 2020-02-14 03:39:57 -0600 )edit

This CMakeLists.txt looks OK as well.

However, the files you've posted don't all match with your error messages. The project in the error message is ros2_fr, the project in the CMakeLists.txt is fr_ros2 and the project in the package.xml is frgen_ros2

Please make them consistent, and check you've posted the right files.

Carl D gravatar imageCarl D ( 2020-02-14 10:20:05 -0600 )edit