我试图在我的mac上设置openCV并使用C ++在Eclipse中使用它。 但我认为链接器有问题。 我在此处描述了所有库:http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html
我尝试了链接器命令g++
和g++ -std=c++11
,但始终收到相同的错误消息:
g++ -L/usr/local/lib -o camera src/Camera.o -lopencv_core -lopencv_ml -
lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_flann -lopencv_imgproc -lopencv_highgui
Undefined symbols for architecture x86_64:
"cv::imread(cv::String const&, int)", referenced from:
_main in Camera.o
ld: symbol(s) not found for architecture x86_64
代码如下:
#include "/usr/local/include/opencv/cv.hpp"
#include "/usr/local/include/opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
答案 0 :(得分:4)
imread
已在opencv_imgcodecs库中移动。
尝试将-lopencv_imgcodecs添加到链接器标志。