error when build catkin package
I have already make a catkin work space following the ROS tutorial. And I also have created a catkin package in source folder. So next I tried to build the catkin package. Everything works before I add the c++ source file into the source folder of the catkin package. After I add the c++ source file, configuration step works fine. But next when I run "make" to build the package, this kind of error appears. It seems it cannot find ROS library.
CMakeFiles/joy_teleop_node.dir/src/joy_teleop_node.cpp.o: In function `TeleopTurtle::TeleopTurtle()':
joy_teleop_node.cpp:(.text+0x37): undefined reference to `ros::NodeHandle::NodeHandle(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)'
joy_teleop_node.cpp:(.text+0x2a2): undefined reference to `ros::Publisher::~Publisher()'
joy_teleop_node.cpp:(.text+0x366): undefined reference to `ros::Subscriber::~Subscriber()'
joy_teleop_node.cpp:(.text+0x443): undefined reference to `ros::Publisher::~Publisher()'
joy_teleop_node.cpp:(.text+0x470): undefined reference to `ros::Subscriber::~Subscriber()'
joy_teleop_node.cpp:(.text+0x4ae): undefined reference to `ros::Subscriber::~Subscriber()'
joy_teleop_node.cpp:(.text+0x4c0): undefined reference to `ros::Publisher::~Publisher()'
joy_teleop_node.cpp:(.text+0x4cf): undefined reference to `ros::NodeHandle::~NodeHandle()'
This is package.xml:
<?xml version="1.0"?>
<package>
<name>joy_teleop</name>
<version>0.0.0</version>
<description>The joy_teleop package</description>
<maintainer email="quan1992@wpi.edu">adrian</maintainer>
<license>BSD</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>joy</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>turtlesim</build_depend>
<run_depend>joy</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>turtlesim</run_depend>
<export>
</export>
</package>
And this is CMakeList.txt
cmake_minimum_required(VERSION 2.8.3)
project(joy_teleop)
find_package(catkin REQUIRED COMPONENTS joy roscpp turtlesim)
catkin_package(
INCLUDE_DIRS include
)
include_directories(include
${catkin_INCLUDE_DIRS}
)
add_executable(joy_teleop_node src/joy_teleop_node.cpp)
I can build the source file using rosbuild method, but not catkin.
Anyone can help me? Thanks in advance!
Is this part of a tutorial? If so, can you tell us the URL of the tutorial so that someone can correct / add clarification to it?
Yeah, I have added the link to my question.
Thanks. I modified wiki