opencv undefined reference problem
I am trying to build learning_image_transport from image_transport tutorial on Gumstix Overo which has ros groovy running on linaro.
However, one of dependencies of learning_image_transport -- opencv2 cannot be resolved in system dependency. So I cannot use rosdep to install opencv2.
Then I went to http://opencv.org/downloads.html and downloaded version 2.4.3 and followed instruction to install OpenCV.
Then I copy opencv and opencv2 from usr/local/include to /ros_core_ws/install/include so that ROS can find all the header file of OpenCV(such as highgui.h).
However, when I make learning_image_transport, I got the following error:
[ 50%] Building CXX object CMakeFiles/my_publisher.dir/src/my_publisher.cpp.o
In file included from /root/ros_core_ws/install/include/opencv2/flann/kmeans_index.h:50:0,
from /root/ros_core_ws/install/include/opencv2/flann/all_indices.h:38,
from /root/ros_core_ws/install/include/opencv2/flann/flann_base.hpp:44,
from /root/ros_core_ws/install/include/opencv2/flann/flann.hpp:50,
from /root/ros_core_ws/install/include/opencv/cv.h:69,
from /root/catkin_ws/src/vision_opencv-fuerte-devel/cv_bridge/include/cv_bridge/CvBridge.h:41,
from /root/catkin_ws/src/learning_image_transport/src/my_publisher.cpp:5:
/root/ros_core_ws/install/include/opencv2/flann/logger.h:73:9: note: the mangling of ‘va_list’ has changed in GCC 4.4
In file included from /root/catkin_ws/src/learning_image_transport/src/my_publisher.cpp:5:0:
/root/catkin_ws/src/vision_opencv-fuerte-devel/cv_bridge/include/cv_bridge/CvBridge.h: In static member function ‘static sensor_msgs::Image_<std::allocator<void> >::Ptr sensor_msgs::CvBridge::cvToImgMsg(const IplImage*, std::string)’:
/root/catkin_ws/src/vision_opencv-fuerte-devel/cv_bridge/include/cv_bridge/CvBridge.h:408:55: warning: ‘static bool sensor_msgs::CvBridge::fromIpltoRosImage(const IplImage*, sensor_msgs::Image&, std::string)’ is deprecated (declared at /root/catkin_ws/src/vision_opencv-fuerte-devel/cv_bridge/include/cv_bridge/CvBridge.h:307) [-Wdeprecated-declarations]
/root/catkin_ws/src/learning_image_transport/src/my_publisher.cpp: In function ‘int main(int, char**)’:
/root/catkin_ws/src/learning_image_transport/src/my_publisher.cpp:15:84: warning: ‘static sensor_msgs::Image_<std::allocator<void> >::Ptr sensor_msgs::CvBridge::cvToImgMsg(const IplImage*, std::string)’ is deprecated (declared at /root/catkin_ws/src/vision_opencv-fuerte-devel/cv_bridge/include/cv_bridge/CvBridge.h:405) [-Wdeprecated-declarations]
Linking CXX executable ../bin/my_publisher
CMakeFiles/my_publisher.dir/src/my_publisher.cpp.o: In function `cv::WImageBufferC<unsigned char, 3>::ReleaseImage()':
/root/ros_core_ws/install/include/opencv2/core/wimage.hpp:399: undefined reference to `cvReleaseImage'
/root/ros_core_ws/install/include/opencv2/core/wimage.hpp:399: undefined reference to `cvReleaseImage'
CMakeFiles/my_publisher.dir/src/my_publisher.cpp.o: In function `sensor_msgs::CvBridge::fromIpltoRosImage(_IplImage const*, sensor_msgs::Image_<std::allocator<void> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/root/catkin_ws/src/vision_opencv-fuerte-devel/cv_bridge/include/cv_bridge/CvBridge.h:311: undefined reference to `cvGetMat'
CMakeFiles/my_publisher.dir/src/my_publisher.cpp.o: In function `main':
/root/catkin_ws/src/learning_image_transport/src/my_publisher.cpp:14: undefined reference to `cvLoadImage'
In wimage.hpp file, it includes opencv2/core/core_c.h which defines:
CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels );
CVAPI(void) cvReleaseImage( IplImage** image );
CVAPI(void*) cvLoad( const char* filename,
CvMemStorage* memstorage CV_DEFAULT(NULL),
const char* name CV_DEFAULT(NULL),
const char** real_name CV_DEFAULT(NULL) );
However, in opencv2/core/types_c.h which is included ...