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

catkin returns array of functions in opencv

asked 2014-01-15 13:51:16 -0500

ProstoTsar gravatar image

updated 2014-01-28 17:19:03 -0500

ngrennan gravatar image

I am trying to do wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages

But I get this error:

Linking CXX executable image_converter CMakeFiles/image_converter.dir/src/image_converter.cpp.o: In function main': image_converter.cpp:(.text+0x50): undefined reference to ros::init(int&, char**, std::basic_string<char, std::char_traits<char="">, std::allocator<char> > const&, unsigned int)'

and so on

My CmakeLists.txt

cmake_minimum_required(VERSION 2.8.3) project(learning_image_transport)

find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})

add_executable(image_converter src/image_converter.cpp)
target_link_libraries(image_converter ${OpenCV_LIBRARIES})

find_package(catkin REQUIRED COMPONENTS genmsg cv_bridge
image_transport roscpp std_msgs )

And Package.xml

<buildtool_depend>catkin</buildtool_depend> <buildtool_depend>genmsg</buildtool_depend> <build_depend>image_transport</build_depend> <build_depend>roscpp</build_depend>
<build_depend>std_msgs</build_depend> <build_depend>cv_bridge</build_depend> <build_depend>opencv2</build_depend>
<run_depend>opencv2</run_depend>
<run_depend>cv_bridge</run_depend>
<run_depend>image_transport</run_depend> <run_depend>roscpp</run_depend>
<run_depend>std_msgs</run_depend>

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-01-15 19:29:22 -0500

Wolf gravatar image

updated 2014-01-16 05:03:39 -0500

Besides ${OpenCV_LIBRARIES} you need to link your exec against ${catkin_LIBRARIES}:

target_link_libraries(image_converter ${OpenCV_LIBRARIES} ${catkin_LIBRARIES} )

Note that you need to call

find_package(catkin REQUIRED COMPONENTS genmsg cv_bridge image_transport roscpp std_msgs )

before target_link_libraries

edit flag offensive delete link more

Comments

I have already tried this but nothing changed

ProstoTsar gravatar image ProstoTsar  ( 2014-01-16 00:11:10 -0500 )edit

Looking at the order in your CMakeLists.txt: Could be that you have to call 'find_package(catkin REQUIRED COMPONENTS genmsg cv_bridge image_transport roscpp std_msgs )' before add_executable and target_link_libraries ....?

Wolf gravatar image Wolf  ( 2014-01-16 00:20:27 -0500 )edit

No, my Cmakelists order is: include_directories(${catkin_INCLUDE_DIRS}) find_package(OpenCV) ... add_executable... target_link_libraries.... CATKIN_DEPENDS roscpp std_msgs cv_bridge image_geometry image_transport DEPENDS system_lib opencv genmsg find_package(catkin REQUIRED COMPONENTS ...

ProstoTsar gravatar image ProstoTsar  ( 2014-01-16 03:55:55 -0500 )edit
1

Why don't you put find_package( catkin REQUIRED COMPONENTS ... to the top of your file, ( before target_link_libraries(image_converter ${OpenCV_LIBRARIES} ${catkin_LIBRARIES} ) ? The var ${catkin_LIBRARIES} depends on it, so I think find_package( catkin must be called first!?

Wolf gravatar image Wolf  ( 2014-01-16 04:19:15 -0500 )edit
1

Thanks a lot, now it is everything OK

ProstoTsar gravatar image ProstoTsar  ( 2014-01-16 04:39:31 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-01-15 13:51:16 -0500

Seen: 180 times

Last updated: Jan 16 '14