Undefined reference to ros::init
Hi! When I am trying to catkin_make, I am getting this error:
CMakeFiles/parser.dir/src/parser.cpp.o: In function `main':
parser.cpp:(.text+0x7e): undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
parser.cpp:(.text+0xda): undefined reference to `ros::NodeHandle::NodeHandle(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
parser.cpp:(.text+0x1ac): undefined reference to `ros::spin()'
parser.cpp:(.text+0x1c0): undefined reference to `ros::Subscriber::~Subscriber()'
parser.cpp:(.text+0x1cf): undefined reference to `ros::NodeHandle::~NodeHandle()'
parser.cpp:(.text+0x22d): undefined reference to `ros::NodeHandle::~NodeHandle()'
parser.cpp:(.text+0x25e): undefined reference to `ros::NodeHandle::~NodeHandle()'
parser.cpp:(.text+0x28f): undefined reference to `ros::Subscriber::~Subscriber()'
parser.cpp:(.text+0x2c6): undefined reference to `ros::Subscriber::~Subscriber()'
parser.cpp:(.text+0x2da): undefined reference to `ros::Subscriber::~Subscriber()'
parser.cpp:(.text+0x2ee): undefined reference to `ros::NodeHandle::~NodeHandle()'
I am not sure why the error is coming from.
My executable file name is parser.cpp
This is my CMakeLists.txt
:
cmake_minimum_required(VERSION 2.8.3)
project(gmm)
find_package(catkin REQUIRED)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES gmm
# CATKIN_DEPENDS other_catkin_pkg
# DEPENDS system_lib
)
#############
## Testing ##
#############
include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(parser src/parser.cpp)
target_link_libraries(parser ${catkin_LIBRARIES})
This is my package.xml
:
<?xml version="1.0"?>
<package>
<name>gmm</name>
<version>0.0.0</version>
<description>The gmm package</description>
<maintainer email="joy@todo.todo">joy</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>std_msgs</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>roscpp</build_depend>
<run_depend>std_msgs</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>roscpp</run_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
Could you please help me out here?