build errors when trying to use CVbridge with ROS Hydro
I'm trying to follow this tutorial - http://wiki.ros.org/cv_bridge/Tutoria...
to stream images to a node.
After I added the node see_image.cpp
, I'm adding an executable by name image_viewer
.
To be clearer, my CMakeLists.txt
looks like this -
cmake_minimum_required(VERSION 2.8.3)
project(visual_odometry)
find_package(catkin REQUIRED COMPONENTS
ardrone_autonomy
roscpp
rospy
sensor_msgs
cv_bridge
std_msgs
image_transport
)
include_directories(
${catkin_INCLUDE_DIRS}
)
add_executable(subscriber_test src/subscriber.cpp)
target_link_libraries(subscriber_test
${catkin_LIBRARIES}
)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(image_viewer src/see_image.cpp)
target_link_libraries(image_viewer ${OpenCV_LIBRARIES})
And my package.xml
looks like this:
<package>
<name>visual_odometry</name>
<version>0.0.0</version>
<description>The visual_odometry package</description>
<maintainer email="voladoddi@todo.todo">voladoddi</maintainer>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>ardrone_autonomy</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<!--adding build_depend and run_depend according to page http://wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages Example 1.4 - ROS node-->
<build_depend>sensor_msgs</build_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>image_transport</build_depend>
<run_depend>ardrone_autonomy</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<!--run dependencies for the 4 build dependencies added above-->
<run_depend>sensor_msgs</run_depend>
<run_depend>cv_bridge</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>image_transport</run_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- You can specify that this package is a metapackage here: -->
<!-- <metapackage/> -->
<!-- Other tools can request additional information be placed here -->
</export>
</package>
After all this, I try to build using catkin_make
and I'm getting the following errors:
Linking CXX executable /home/voladoddi/catkin_ws/devel/lib/visual_odometry/image_viewer
[ 5%] Performing install step for 'ardronelib'
make[3]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
[ 6%] Completed 'ardronelib'
[ 8%] Built target ardronelib
[ 9%] Built target subscriber_test
CMakeFiles/image_viewer.dir/src/see_image.cpp.o: In function `main':
see_image.cpp:(.text+0x55): undefined reference to `ros::init(int&, char**, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
see_image.cpp:(.text+0x81): undefined reference to `ros::spin()'
CMakeFiles/image_viewer.dir/src/see_image.cpp.o: In function `image_transport::TransportHints::TransportHints(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::TransportHints const&, ros::NodeHandle const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
see_image.cpp:(.text._ZN15image_transport14TransportHintsC2ERKSsRKN3ros14TransportHintsERKNS3_10NodeHandleES2_[_ZN15image_transport14TransportHintsC5ERKSsRKN3ros14TransportHintsERKNS3_10NodeHandleES2_]+0x53): undefined reference to `ros::NodeHandle::NodeHandle(ros::NodeHandle const&)'
see_image.cpp:(.text._ZN15image_transport14TransportHintsC2ERKSsRKN3ros14TransportHintsERKNS3_10NodeHandleES2_[_ZN15image_transport14TransportHintsC5ERKSsRKN3ros14TransportHintsERKNS3_10NodeHandleES2_]+0x84): undefined reference to `ros::NodeHandle::~NodeHandle()'
CMakeFiles/image_viewer.dir/src/see_image.cpp.o: In function `image_transport::TransportHints::~TransportHints()':
see_image.cpp:(.text._ZN15image_transport14TransportHintsD2Ev[_ZN15image_transport14TransportHintsD5Ev]+0x19): undefined reference to `ros::NodeHandle::~NodeHandle()'
CMakeFiles/image_viewer.dir/src/see_image.cpp.o: In function `ImageConverter::ImageConverter()':
see_image.cpp:(.text._ZN14ImageConverterC2Ev[_ZN14ImageConverterC5Ev]+0x47): 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&)'
see_image.cpp:(.text._ZN14ImageConverterC2Ev[_ZN14ImageConverterC5Ev]+0x82): undefined reference to `image_transport::ImageTransport ...
can you post your
.cpp
fileI needed to add a target library for the new executable on
catkin_libraries
. worked. Thank you. However, still not able to see the images.Do have a look at the .cpp file.