2012-11-26 82 views
1

我想玩弄OpenCV cv::SimpleBlobDetector,但編譯我的代碼時出現以下錯誤:當使用「cv :: SimpleBlobDetector」時,OSX 10.7.5 + OpenCV 2.4.3:「架構x86_64的未定義符號」

Ld /Users/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Products/Debug/blob-test-opencv.app/Contents/MacOS/blob-test-opencv normal x86_64 
    cd /Users/dom/Desktop/blob-test-opencv 
    setenv MACOSX_DEPLOYMENT_TARGET 10.7 

    /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/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Products/Debug \ 
    -L/usr/local/Cellar/opencv/2.4.3/lib \ 
    -F/Users/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Products/Debug \ 
    -filelist /Users/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Intermediates/blob-test-opencv.build/Debug/blob-test-opencv.build/Objects-normal/x86_64/blob-test-opencv.LinkFileList \ 
    -mmacosx-version-min=10.7 \ 
    -fobjc-arc \ 
    -fobjc-link-runtime \ 
    -stdlib=libc++ \ 
    -lopencv_calib3d.2.4.3 \ 
    -lopencv_contrib.2.4.3 \ 
    -lopencv_core.2.4.3 \ 
    -lopencv_features2d.2.4.3 \ 
    -lopencv_flann.2.4.3 \ 
    -lopencv_gpu.2.4.3 \ 
    -lopencv_highgui.2.4.3 \ 
    -lopencv_imgproc.2.4.3 \ 
    -lopencv_legacy.2.4.3 \ 
    -lopencv_ml.2.4.3 \ 
    -lopencv_nonfree.2.4.3 \ 
    -lopencv_objdetect.2.4.3 \ 
    -lopencv_photo.2.4.3 \ 
    -lopencv_stitching.2.4.3 \ 
    -lopencv_ts.2.4.3 \ 
    -lopencv_video.2.4.3 \ 
    -lopencv_videostab.2.4.3 \ 
    -framework Cocoa -o /Users/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Products/Debug/blob-test-opencv.app/Contents/MacOS/blob-test-opencv 

Undefined symbols for architecture x86_64: 
    "cv::drawKeypoints(cv::Mat const&, std::__1::vector<cv::KeyPoint, std::__1::allocator<cv::KeyPoint> > const&, cv::Mat&, cv::Scalar_<double> const&, int)", referenced from: 
     BlobTest::detectBlobs(cv::Mat) in blob-detector.o 
    "cv::FeatureDetector::detect(cv::Mat const&, std::__1::vector<cv::KeyPoint, std::__1::allocator<cv::KeyPoint> >&, cv::Mat const&) const", referenced from: 
     BlobTest::detectBlobs(cv::Mat) in blob-detector.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

的代碼,我寫這個樣子的:

cv::SimpleBlobDetector::Params params; 

params.minDistBetweenBlobs = 10.0; 
params.filterByArea = true; 
params.minArea = 500.0; 
params.maxArea = 1500.0; 

cv::SimpleBlobDetector myBlobDetector(params); 
std::vector<cv::KeyPoint> myBlobs; 

myBlobDetector.detect(image, myBlobs); 

cv::Mat blobImg; 
cv::drawKeypoints(image, myBlobs, blobImg); 

我的頭前綴文件中包含的OpenCV:

#ifdef __cplusplus 
    #import "opencv2/opencv.hpp" 
#endif 

我在OSX 10.7.5上使用OpenCV 2.43(通過brew)在4.52上運行Xcode。

據我可以告訴所有需要的庫鏈接正確(特別是opencv_features2d.2.4.3)和OpenCV編譯爲我的64位系統。其他OpenCV代碼一直在正常工作...我錯過了什麼嗎?

回答

3

在xcode的左側,選擇您的項目名稱。右側窗口中,去

Buil Settings>Build Options> Compiler for C/C++/Objective-C 

改變它Apple LLVM CompilerLLVM GCC 4.2

乾杯,

+1

這個解決方案給我, 「不支持的編譯器」。 –

0

以上回答din't爲我工作。

轉到構建設置>蘋果LLVM 5.0 - 語言 - C++> C++標準庫,選擇的libC++

+0

此解決方案導致更多未定義的符號,如cv :: VideoWriter :: open ... –

相關問題