OpenCV on OSX Mavericks with Xcode

I'm trying to run OpenCV on OSX in Xcode. I have downloaded the code from github. And used cmake to compile it.

Next I created a new Xcode project with the following code:

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

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    if( argc != 2)
    {
        cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
        return -1;
    }

    Mat image;
    image = imread("img.jpg");   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window

    return 0;
}

Next I've set the header search path to: /usr/local/include

After that I've added the libraries from /usr/local/lib in the "Build Phases" as seen in the screenshot below.

image description http://answers.opencv.org/upfiles/13912699992370041.png

However, when I try to run I get the following error:

ld: library not found for -lopencv_core.3.0.0
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Did I mis something?


In search for header path, double tap the property. if you see the empty string don't enter there, slowly tap twice as it pop up a new list of properties add the new one under the values press enter

still if its not working , check your string


您还应该将/usr/local/lib添加到库搜索路径中。

链接地址: http://www.djcxy.com/p/68808.html

上一篇: Xcode 5在usr / include中找不到头文件

下一篇: 使用Xcode的OSX Mavericks上的OpenCV