2009-12-03 3 views
1

설명 here과 같이 cmake 빌드 시스템을 사용하여 OpenCV 라이브러리를 빌드했으며 '.a'및 '.dylib'파일을 터미널 C++ 프로젝트에 추가했습니다. 그러나 아래 코드를 실행하면 (http://iphone-cocoa-objectivec.blogspot.com/2009/01/using-opencv-for-mac-os-in-xcode.html에서 가져옴) 아래 오류가 표시됩니다. 누구 조언있어? 어떤 도움을 많이 주시면 감사하겠습니다.Xcode에서 OpenCV C++ 오류

#include <stdlib.h> 
#include <stdio.h> 
#include <math.h> 
#include <cv.h> 
#include <highgui.h> 

int main() 
{ 

    //get the image from the directed path 
    IplImage* img = cvLoadImage("/Users/somedir/Programming/TestProj/fruits.jpg", 1); 

    //create a window to display the image 
    cvNamedWindow("picture", 1); 

    //show the image in the window 
    cvShowImage("picture", img); 

    //wait for the user to hit a key 
    cvWaitKey(0); 

    //delete the image and window 
    cvReleaseImage(&img); 
    cvDestroyWindow("picture"); 

    //return 
    return 0; 
} 

오류 OpenCV의 2.0 엑스 코드를 사용하여

Undefined symbols: 
    "_cvLoadImage", referenced from: 
     _main in main.o 
    "_cvNamedWindow", referenced from: 
     _main in main.o 
    "_cvReleaseImage", referenced from: 
     _main in main.o 
    "_cvShowImage", referenced from: 
     _main in main.o 
    "_cvDestroyWindow", referenced from: 
     _main in main.o 
    "_cvWaitKey", referenced from: 
     _main in main.o 
ld: symbol(s) not found 
collect2: ld returned 1 exit status 

답변

0

마십시오. OpenCV를 사용하는 경우 Windows를 사용하고 OpenCV 1.1도 사용하십시오. 두통을 많이 줄여줍니다. 2.0/Mac이 더 잘 문서화되면 Mac 플랫폼/2.0 버전으로 전환됩니다. 책 (O'Reilly)이 좋다 - v1.1을 다룬다. 2.0의 다음 기사는 곧 뒤따라야합니다. 모든 1.

0

첫째, Mac에서 MacPorts를에서 그들을 얻을, 당신은 쉽게 한 라이너와 함께 최신 버전으로 업데이트 할 수 있습니다 ...

플러스를 더 CMake와 libs와 구축하지 않습니다 ,
#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>과 함께 cv::Mat 인터페이스를 사용한다면 더 좋을 것입니다 ...;) 이름 끝에 버전이 포함 된 dylib 라이브러리를 포함하십시오. 우선

(나는 버전없는 dylibs 이전 인터페이스 사용법 #include에 대한 생각) :

#include <opencv2/core/core.hpp> 
#include <opencv2/highgui/highgui.hpp> 
using namespace cv; 
int main() 
{ 

    //get the image from the directed path 
    Mat img = loadImage("/Users/somedir/Programming/TestProj/fruits.jpg"); 

    //show the image in the window 
    imshow("picture", img); 

    //wait for the user to hit a key 
    waitKey(0); 
    //delete the image and window (automatic) 
    return 0; 
} 
관련 문제