Ask Your Question

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

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)


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>image_transport</run_depend> <run_depend>roscpp</run_depend>

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

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


I have already tried this but nothing changed

ProstoTsar gravatar imageProstoTsar ( 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 imageWolf ( 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 imageProstoTsar ( 2014-01-16 03:55:55 -0500 )edit

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 imageWolf ( 2014-01-16 04:19:15 -0500 )edit

Thanks a lot, now it is everything OK

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


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

Seen: 71 times

Last updated: Jan 16 '14