2

Im trying to set up openCV on my mac and work with it in Eclipse with C++. But I think somthing is wrong with the linker. I included all libraries as described here: http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html

I tried the linker commands g++ and g++ -std=c++11 but get always the same error message:

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

for the following code:

#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;
}
1
  • 2
    if that is opencv3.0, you will need -lopencv_imgcodecs for imread(). also, please do not use absolute path, but #include<opencv2/opencv.hpp> Commented May 28, 2015 at 11:13

1 Answer 1

7

imread has been moved in the opencv_imgcodecs library.

Try to add -lopencv_imgcodecs to your linker flags.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, somehow I missed this one!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.