编译错误Xcode 4.3.1 - > OpenCv Framework

时间:2012-03-15 22:31:37

标签: xcode frameworks opencv

我尝试使用openCV安装MAcPort,但我检索了一些错误。所以我下载了框架文件夹,我把它添加到xcode链接库。现在,当我编写代码并构建它时,我检索到了这个错误:

ld: warning: ignoring file /Volumes/OpenCV2.0/OpenCV.framework/OpenCV, missing required architecture x86_64 in file
Undefined symbols for architecture x86_64:
  "_cvCreateCameraCapture", referenced from:
      _main in main.o
  "_cvQueryFrame", referenced from:
      _main in main.o
  "_cvGetSize", referenced from:
      _main in main.o
  "_cvCreateImage", referenced from:
      _main in main.o
  "_cvCvtColor", referenced from:
      _main in main.o
  "_cvShowImage", referenced from:
      _main in main.o
  "_cvWaitKey", referenced from:
      _main in main.o
  "_cvDestroyAllWindows", referenced from:
      _main in main.o
  "_cvReleaseImage", referenced from:
      _main in main.o
  "_cvCreateHist", referenced from:
      _create_histogram_image in main.o
  "_cvGetMinMaxHistValue", referenced from:
      _create_histogram_image in main.o
  "_cvConvertScale", referenced from:
      _create_histogram_image in main.o
  "_cvSet", referenced from:
      _create_histogram_image in main.o
  "_cvGetReal1D", referenced from:
      _create_histogram_image in main.o
  "_cvRectangle", referenced from:
      _create_histogram_image in main.o
  "_cvReleaseHist", referenced from:
      _create_histogram_image in main.o
  "_cvCalcArrHist", referenced from:
      _cvCalcHist 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)

有没有人有同样的错误?你能帮助我吗???谢谢!!

3 个答案:

答案 0 :(得分:2)

我也遇到了与JackTurky提到的相同的问题,使用从Mountain Lion上的Xcode 4.5上的macports安装的opencv 2.4.2。我尝试将默认编译器从Apple LLVM编译器4.1更改为LLVM GCC 4.2,但随后出现了与@autoreleasepool和ARC以及一般目标c语法相关的其他问题。幸运的是,我有一个Xcode项目,最初使用Snow Leopard上的Xcode 3.2构建,仍然可以使用我当前的设置。我仔细比较了工作和破坏项目的构建设置。因此,使用Apple LLVM编译器4.1并进行构建设置 - > Apple LLVM编译器4.1语言 - > C ++标准库,我从libc ++(...)更改为libstdc ++(..),当你再次构建项目时,所有错误都消失了。适合我,希望这有帮助。

答案 1 :(得分:1)

您使用的是GCC 4.2编译器吗? XCode4默认使用LLVM,而openCV与它不兼容(尚未)。 要检查单击项目,请转到构建设置,搜索“编译器”。

答案 2 :(得分:0)

我建议你试试这个:

http://aptogo.co.uk/2011/09/face-tracking/

直接复制框架,然后将其添加到您的prefix.pch

#ifdef __cplusplus
#import <OpenCV/opencv2/opencv.hpp>
#endif

它应该非常容易。