无法使用XCode 4编译OpenCV项目

时间:2012-08-04 19:23:02

标签: opencv xcode4

我在Mac上成功构建了OpenCV,但无法使用XCode编译一个简单的OpenCV项目。

我将libopencv_core,libopencv_highgui和libopencv_imgproc添加到项目中的文件组。

这是链接器输出:

/Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Products/Debug/opencv_test normal x86_64
    cd /Users/petilodie/Projects/Test/opencv_test
    setenv MACOSX_DEPLOYMENT_TARGET 10.8
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Products/Debug -F/Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Products/Debug -filelist /Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Intermediates/opencv_test.build/Debug/opencv_test.build/Objects-normal/x86_64/opencv_test.LinkFileList -mmacosx-version-min=10.8 -o /Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Products/Debug/opencv_test

Undefined symbols for architecture x86_64:
  "_cvDestroyWindow", referenced from:
      _main in main.o
  "_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
  "_cvWaitKey", 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)

以下是main.cpp中的代码:

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

int main(int argc, const char * argv[])
{
    IplImage* img = cvLoadImage( argv[1] );
    cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    cvShowImage( "Example1", img );
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow( "Example1" );
}

那么,这里有什么问题?

1 个答案:

答案 0 :(得分:0)

您需要将库链接到二进制文件:

Build settings