Ask Your Question

New problem linking OpenCV Indigo Cplusplus node

asked 2017-04-23 11:30:25 -0500

burtbick gravatar image

Indigo, Ubuntu 14.04 (Linux Mint 17.1)

I had a problem the other day that turned out to be missing find_package(OpenCV) so that was resolved.
But I have a new one. I have a better tracking test that builds and runs fine outside of ROS. But catkin_make gives this:

catkin_make Base path: /home/bbick/ros_ws Source space: /home/bbick/ros_ws/src Build space: /home/bbick/ros_ws/build Devel space: /home/bbick/ros_ws/devel Install space: /home/bbick/ros_ws/install ####

Running command: "make cmake_check_build_system" in "/home/bbick/ros_ws/build"

#### ####

Running command: "make -j6 -l6" in "/home/bbick/ros_ws/build"

#### [ 0%] Built target dynamic_reconfigure_generate_messages_py [ 0%] [ 0%] Built target roscpp_generate_messages_lisp Built target roscpp_generate_messages_cpp [ 11%] Built target talker [ 22%] Linking CXX executable /home/bbick/ros_ws/devel/lib/inmoovhead/myopencvtest Built target listener [ 22%] Built target roscpp_generate_messages_py [ 22%] [ 22%] [ 22%] Built target std_msgs_generate_messages_lisp Built target std_msgs_generate_messages_py Built target rosgraph_msgs_generate_messages_py [ 22%] Built target rosgraph_msgs_generate_messages_lisp [ 22%] Built target rosgraph_msgs_generate_messages_cpp [ 22%] [ 22%] Built target dynamic_reconfigure_gencfg [ 33%] Built target pid_gencfg [ 33%] Built target std_msgs_generate_messages_cpp Built target dynamic_reconfigure_generate_messages_cpp [ 33%] Built target dynamic_reconfigure_generate_messages_lisp [ 33%] Built target diagnostic_msgs_generate_messages_cpp [ 33%] [ 33%] Built target diagnostic_msgs_generate_messages_lisp Built target diagnostic_msgs_generate_messages_py [ 44%] [ 55%] Built target autotune Built target setpoint_node [ 66%] Built target plant_sim [ 77%] Built target controller [ 88%] Built target sim_time CMakeFiles/myopencvtest.dir/src/myopencvtest.cpp.o: In function main': myopencvtest.cpp:(.text+0x46e): undefined reference tocv::CommandLineParser::CommandLineParser(int, char const* const, cv::String const&)' myopencvtest.cpp:(.text+0x4aa): undefined reference to cv::CommandLineParser::has(cv::String const&) const' myopencvtest.cpp:(.text+0x54c): undefined reference tocv::CommandLineParser::printMessage() const' myopencvtest.cpp:(.text+0x8e5): undefined reference to cv::namedWindow(cv::String const&, int)' myopencvtest.cpp:(.text+0x91c): undefined reference tocv::namedWindow(cv::String const&, int)' myopencvtest.cpp:(.text+0x958): undefined reference to cv::setMouseCallback(cv::String const&, void (*)(int, int, int, int, void*), void*)' myopencvtest.cpp:(.text+0x9bb): undefined reference tocv::createTrackbar(cv::String const&, cv::String const&, int, int, void ()(int, void), void)' myopencvtest.cpp:(.text+0xa2d): undefined reference to cv::createTrackbar(cv::String const&, cv::String const&, int*, int, void (*)(int, void*), void*)' myopencvtest.cpp:(.text+0xa9f): undefined reference tocv::createTrackbar(cv::String const&, cv::String const&, int, int, void ()(int, void), void)' myopencvtest.cpp:(.text+0xff0): undefined reference to cv::normalize(cv::_InputArray const&, cv::_InputOutputArray const&, double, double, int, int, cv::_InputArray const&)' myopencvtest.cpp:(.text+0x12b4): undefined reference tocv::rectangle(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)' myopencvtest.cpp:(.text+0x176c): undefined reference to cv::ellipse(cv::_InputOutputArray const&, cv::RotatedRect const&, cv::Scalar_<double> const&, int, int)' myopencvtest.cpp:(.text+0x18aa): undefined reference tocv::imshow(cv::String const&, cv::_InputArray const&)' myopencvtest.cpp:(.text+0x190e): undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)' myopencvtest.cpp:(.text+0x1a09): undefined reference tocv::destroyWindow(cv::String const&)' myopencvtest.cpp:(.text+0x1a42): undefined reference to cv::namedWindow(cv::String const&, int)' myopencvtest.cpp:(.text+0x1b39): undefined reference tocv::CommandLineParser::~CommandLineParser()' myopencvtest ... (more)

edit retag flag offensive close merge delete


Please add your CMakeList.txt so people can help you.

mohsen1989m gravatar image mohsen1989m  ( 2017-04-23 13:24:57 -0500 )edit

I ran a cut-down version of your CMakeLists.txt on the first OpenCV sample (contours2.cpp), and it compiled fine. Please post your source files and the complete output of catkin_make so we can see what values it is finding when it searches for OpenCV.

Geoff gravatar image Geoff  ( 2017-04-23 18:55:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-23 20:35:37 -0500

burtbick gravatar image

updated 2017-04-23 20:36:31 -0500

I had pasted in the CMakeLIsts.txt file contents, just removed most of the commented lines to try and keep it brief, but it looks like the editor here mucked it up, or there is some different way to enter the code that cleans it up.


Here's a link to the CMakeLists.txt file (renamed to BBCMakeLists.txt, only for this download)

My CMakeLists.txt

And to the OpenCV sample that I've enhanced to track my robot head. Note that this sample DOES not have the ROS code in but it has the same linking errors as my full application. Note also that I built the version of the app that integrates with ROS externally and it runs fine with ROS, and I have my head tracking well. But it won't link when built with the ROS build system using catkin_make. Other OpenCV tests I've done HAVE built and linked OK with catkin_make.

My Sample C++ File

Here's the only output I get from catkin_make, note I did a catkin_make clean first and then catkin_make

Since pasting the catkin_make output also seems to jumble up, here's a link to the output that I get:

catkin_make output

You should be able to download the files with no problems, but let me know if there is a problem.

Thanks, Burt

edit flag offensive delete link more


You need to delete the build/ and devel/ directories before running catkin_make, otherwise the configure step is skipped. Delete those two directories, then run VERBOSE=1 catkin_make and post the output.

Geoff gravatar image Geoff  ( 2017-04-24 21:54:23 -0500 )edit

Your code compiled fine for me, by the way.

Geoff gravatar image Geoff  ( 2017-04-24 21:54:48 -0500 )edit

Thanks Geoff,

I deleted build and devel and when I was building to gather the catkin_make output for you it built cleanly!!! The only thing I had done differently was deleting build and devel directory trees. So there must have been something in the old trees that was causing the problem.

burtbick gravatar image burtbick  ( 2017-04-25 08:40:56 -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: 2017-04-23 11:30:25 -0500

Seen: 840 times

Last updated: Apr 23 '17