Error compiling c++ code (ros/ros.h: No such file or directory)
Hello. Im using ubuntu 20.4 , ros noetic and gazebo 11 trying to move a robot using cubic polynomials and c++. At the beginning of the file I have these inlcudes:
#include <ros/ros.h>
#include <tf/tf.h>
#include <geometry_msgs/Twist.h>
#include <geometry_msgs/Pose.h>
#include <nav_msgs/Odometry.h>
#include <math.h>
When I compile the file ,I get this error:
traj_gen_cubic.cpp:1:10: fatal error: ros/ros.h: No such file or directory
1 | #include <ros/ros.h>
| ^~~~~~~~~~~
compilation terminated.
This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8.3)
project(husky_ur3_gazebo)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
roslaunch
)
catkin_package(
CATKIN_DEPENDS roscpp std_msgs
)
include_directories(${catkin_INCLUDE_DIRS})
add_executable(gazebo_rh_pub src/gazebo_rh_pub.cpp)
add_dependencies(gazebo_rh_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(gazebo_rh_pub ${catkin_LIBRARIES})
install(TARGETS gazebo_rh_pub
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY launch controller DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
What should I do?
what's your compile command?are you sure you have source(init) the ros env? as http://wiki.ros.org/ROS/Tutorials/Bui...
g++ traj_gen_cubic.cpp -o traj_gen_cubic
This command is also inside my .bashrc file so I dont have to write it every time $ source /opt/ros/noetic/setup.bash
When i add this line "add_executable(traj_gen_cubic src/traj_gen_cubic.cpp) "in CMakeLists.txt file and I do catkin_make ,I get this error: Invoking "make -j4 -l4" failed
Any ideas??