无法使用XCode 4编译OpenCV项目 [英] Unable to compile OpenCV project with XCode 4
本文介绍了无法使用XCode 4编译OpenCV项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Mac上成功构建了OpenCV,但无法使用XCode编译简单的OpenCV项目.
I successfully built OpenCV on my Mac but couldn't compile a simple OpenCV project with XCode.
我在项目中的文件组中添加了libopencv_core,libopencv_highgui和libopencv_imgproc.
I added libopencv_core, libopencv_highgui and libopencv_imgproc to a file group in project.
这是链接器输出:
/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中的代码:
Here is the code in 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" );
}
那么,这是什么问题?
推荐答案
您需要将库链接到您的二进制文件:
You need to link the libraries to your binary:
这篇关于无法使用XCode 4编译OpenCV项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文