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

No such file or directory [sensor_msgs/LaserScan.h]

asked 2012-02-06 23:32:26 -0500

jlo gravatar image

Hi there, guys, I have been writing some codes that made use of geometry_msgs lately. The way I included them in the previous algorithm was like this:

#include "geometry_msgs/Point.h"

And now I would like to use LaserScan.h, located in my system at



#include "geometry_msgs/Point.h"

The thing is, when I try to compile what I get is this error, showing it can't find it:

  /home/alonsoj1/ros_workspace/prueba/src/talker.cpp:2:48: error: common_msgs/sensor_msgs/CameraInfo.h: No such file or directory

That's why I just link to the whole path like this to make it work:

#include "/opt/ros/electric/stacks/common_msgs/sensor_msgs/msg_gen/cpp/include/sensor_msgs/LaserScan.h"

I wonder why this is necessary, since the file Point.h (the one I used before wasn't in geometry_msgs/ path directly, but in /opt/ros/electric/stacks/common_msgs/geometry_msgs/msg_gen/cpp/include/geometry_msgs). Is there a reason for this behaviour?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-02-07 00:46:21 -0500

DimitriProsser gravatar image

Check your package's manifest.xml. It must say the following:

<depend package="geometry_msgs" />
<depend package="sensor_msgs" />

This will allow CMake to locate the appropriate header files. The other thing to check is to make sure that geometry_msgs is properly located in your ROS_PACKAGE_PATH.

edit flag offensive delete link more


Awesome, exactly what was going on. I had forgotten about manifest.xml dependencies.
jlo gravatar image jlo  ( 2012-02-07 22:21:12 -0500 )edit

answered 2021-03-01 08:47:58 -0500

AndyZe gravatar image

updated 2021-03-01 09:55:53 -0500

gvdhoorn gravatar image

Another cause (as of ROS Melodic in 2021) could be a missing include_directories in package.xml:

include_directories(include ${catkin_INCLUDE_DIRS})
edit flag offensive delete link more

Question Tools


Asked: 2012-02-06 23:32:26 -0500

Seen: 7,973 times

Last updated: Mar 01 '21