image_converter.cpp:1:21: fatal error: ros/ros.h: No such file or directory
compilation terminated.
: rosrun으로 실행 안하고 c++로 실행해서 일어나는 오류!
$ g++ image_converter.cpp 와 같이 실행시 오류발생
[rosrun] Couldn't find executable named image_converter below /home/haei3/catkin_ws/src/image_test
----------------------------------------------------------------------------------------------------------
cvTest.cpp:(.text+0x74): undefined reference to `cv::namedWindow(cv::String const&, int)'
cvTest.cpp:(.text+0x92): undefined reference to `cv::VideoCapture::VideoCapture()'
cvTest.cpp:(.text+0xa6): undefined reference to `cv::VideoCapture::open(int)'
cvTest.cpp:(.text+0xb5): undefined reference to `cv::VideoCapture::isOpened() const'
cvTest.cpp:(.text+0xc2): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
cvTest.cpp:(.text+0x118): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
cvTest.cpp:(.text+0x140): undefined reference to `cv::waitKey(int)'
cvTest.cpp:(.text+0x173): undefined reference to `cv::destroyWindow(cv::String const&)'
cvTest.cpp:(.text+0x196): undefined reference to `cv::VideoCapture::~VideoCapture()'
cvTest.cpp:(.text+0x21b): undefined reference to `cv::VideoCapture::~VideoCapture()'
/tmp/ccJJWQT2.o: In function `cv::String::String(char const*)':
cvTest.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x54): undefined reference to `cv::String::allocate(unsigned long)'
/tmp/ccJJWQT2.o: In function `cv::String::~String()':
cvTest.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
/tmp/ccJJWQT2.o: In function `cv::String::operator=(cv::String const&)':
cvTest.cpp:(.text._ZN2cv6StringaSERKS0_[_ZN2cv6StringaSERKS0_]+0x28): undefined reference to `cv::String::deallocate()'
/tmp/ccJJWQT2.o: In function `cv::Mat::~Mat()':
cvTest.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/ccJJWQT2.o: In function `cv::Mat::release()':
cvTest.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
와 같은 오류가 일어나는 이유는, ROS문제가 아니라 OPENCV문제다.
따라서 먼저, 간단한 C++예제가 돌아가는지 확인하자.
<source>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main() {
VideoCapture cap(0);
if (!cap.isOpened())
{
cout << "cannot open camera";
}
//unconditional loop
while (true) {
Mat cameraFrame;
cap.read(cameraFrame);
imshow("cam", cameraFrame);
if (waitKey(30) >= 0) break;
}
return 0;
}
</source>
$ g++ a.cpp -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio -o openCVtest
: g++라는 프로그램으로/ a.cpp를 실행한다/opencv_core/opencv_highgui/opencv_imgproc/opencv_imgcodecs/opencv_videoio라이브러리를 추가해서/실행파일은 openCVtest라고 이름짓는다.
그래서 Makefile을 쓰는 경우는, LIBRARIES += opencv_core opencv_highgui opencv_imgproc opencv_videoio라고 수정해주란다
(출처 : https://github.com/facebook/C3D/issues/253)
댓글 없음:
댓글 쓰기