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

CLion and ROS: fatal error: ros/ros.h: No such file or directory

asked 2018-02-14 09:32:56 -0500

sonjabrits gravatar image

I am having trouble using ROS Kinetic and CLion, specifically that CLion complains the following when trying to build.

fatal error: ros/ros.h: No such file or directory compilation terminated.

I saw the question https://answers.ros.org/question/2374... , but the answers did not help me.

When I build from commandline using catkin build, everything builds successfully. I presume that CLion does not get the ROS environment variables, since it is the exact same error whether I source or not. I have looked at many tutorials and help pages, but none could solve the problem for me. I have tried the following:

1 Building from command line, sourcing and then launching CLion from same terminal

catkin build
source /opt/ros/kinetic/setup.bash
source devel/setup.bash
cd clion_dir/bin
./clion.sh

2 Adding source /opt/ros/kinetic/setup.bash to the following files

~/.bashrc
/etc/profile
~/.profile

3 Changing the Exec part of ~/.local/share/applications/jetbrains-clion.desktop

Exec=bash -i -c "~/applications/clion-2017.3.3/bin/clion.sh" %f

My CMakeLists.txt looks as follows

cmake_minimum_required(VERSION 2.8.3)
project(example)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
)

catkin_package()

include_directories(${catkin_INCLUDE_DIRS})

add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})

add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})

add_executable(listener2 src/listener2.cpp)
target_link_libraries(listener2 ${catkin_LIBRARIES})
edit retag flag offensive close merge delete

Comments

1

I think CLion doesn't know how to compile your workspace when using catkin build instead of catkin_make. Try catkin_init_workspace in your workspace/src directory and load the created CMakeLists.txt with CLion. You can still build the package with catkin build command from terminal.

l4ncelot gravatar image l4ncelot  ( 2018-02-14 10:11:57 -0500 )edit

Or at least this is how I do it with my workspaces built using catkin build command.

l4ncelot gravatar image l4ncelot  ( 2018-02-14 10:12:41 -0500 )edit

That was exactly the problem! I did catkin_init_workspace in the src directory and after that it worked perfectly. Thanks so much. If you post as answer I'll accept it :)

sonjabrits gravatar image sonjabrits  ( 2018-02-14 11:52:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-02-15 02:28:06 -0500

l4ncelot gravatar image

Try catkin_init_workspace in your workspace/src directory and load the created CMakeLists.txt with CLion. You can still build the package with catkin build command from terminal.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-02-14 09:32:56 -0500

Seen: 2,992 times

Last updated: Feb 15 '18