同样的错误:
Undefined symbols for architecture x86_64:
"cv::applyColorMap(cv::_InputArray const&, cv::_OutputArray const&, int)", referenced from:
_main in test.o
"cv::subspaceProject(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&)", referenced from:
_main in test.o
"cv::subspaceReconstruct(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&)", referenced from:
_main in test.o
"cv::createEigenFaceRecognizer(int, double)", referenced from:
_main in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我尝试的代码是:
https://gist.github.com/hihell/0520674421fe0cb26d38
我已经将C ++标准库更改为"编译器默认"但错误仍然存在。
然而,其他简单的代码,如显示图片或打开相机,可以使用相同的设置正常工作。
版本:
任何帮助或提示都非常受欢迎
答案 0 :(得分:0)
您需要正确指出标题和库搜索路径。
您似乎已正确设置标题路径 要设置库搜索路径,请执行以下操作:
找到"图书馆搜索路径"项目的Xcode中的设置。 Build Settings -> Search Paths -> Library Search Paths
。然后在Debug或Release中,添加OpenCV库路径。 (就我而言,它是&usr / local / lib。)
查找:Buid Phases -> Link Binary With Libraries
,添加* .dylib文件
就我而言,我补充说:
注意,libopencv_contrib.2.4.9.dylib对于您提到的功能至关重要,也可能需要其他功能。
顺便说一句,如果您在添加头文件时遇到问题,那就差不多了。在Build Settings -> Search Paths -> Header Search Paths
下添加它们。