简体   繁体   中英

Can't run OpenCV example in OSX Yosemite (Macbook 8,1)

I want to run OpenCV (opencv-3.0.0-beta) on OSX Yosemite with a Macbook Pro 8,1 and XCode. But I get some issues.

Code I Used:

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"

using namespace cv;

int main(){

VideoCapture cap(0);

while (true){

    Mat Webcam;
    cap.read(Webcam);
    imshow("Webcam", Webcam);

    }

}

I get four issues..

Undefined symbols for architecture x86_64:
  "cv::VideoCapture::read(cv::_OutputArray const&)", referenced from:
      _main in main.o
  "cv::VideoCapture::VideoCapture(int)", referenced from:
      _main in main.o
  "cv::VideoCapture::~VideoCapture()", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The Settings for Search Paths are:

  • Always Search User Paths = Yes
  • Framework Search Paths = /usr/local/lib
  • Header Search Paths = /usr/local/include
  • Library Search Paths = "MyOpenCV-Folder"/build/lib

**Can anybody help?

And please tell me if you need some more information. You'll get them :p

Thanks!**

Converting my comment in an answer:

You probably forgot to actually link against the OpenCV libraries. The libraries need to be explicitly specified, this link shows how you need to do it in Xcode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM