2012-12-18 33 views
0

在OpenCV中使用Features2D時,我一直在爲構建錯誤而戰,我無法弄清楚原因。使用XCode在OpenCV中使用Featured2D構建錯誤

  • OpenCV的版本:2.4.3(MacPorts的)
  • 編譯拱:64位Intel
  • C語言的方言:GNU99
  • C++語言方言:GNU ++ 11
  • C++標準庫:++的libstdc

生成錯誤:

Undefined symbols for architecture x86_64: 
"cv::FeatureDetector::detect(cv::Mat const&, std::__debug::vector<cv::KeyPoint,  std::allocator<cv::KeyPoint> >&, cv::Mat const&) const", referenced from: 
    analysis::openCvStitching() in analysis.o 
"cv::DescriptorMatcher::match(cv::Mat const&, cv::Mat const&, std::__debug::vector<cv::DMatch, std::allocator<cv::DMatch> >&, cv::Mat const&) const", referenced from: 
    analysis::openCvStitching() in analysis.o 
"cv::DescriptorExtractor::compute(cv::Mat const&, std::__debug::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat&) const", referenced from: 
    analysis::openCvStitching() in analysis.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

這是我如何創建一個指向FeatureDetector和DescriptorExtractor:

Ptr<FeatureDetector> surfDetector = FeatureDetector::create(type); 
Ptr<DescriptorExtractor> surfExtractor = DescriptorExtractor::create(type); 

回答

2

您是否嘗試過刪除從預處理器標誌_GLIBCXX_DEBUG=1和/或_GLIBCXX_DEBUG_PEDANTIC=1在您的項目設置? opencv2 C++ api在API函數中使用STL模板時有點不好,如果您的標準庫或編譯器標誌版本與編譯時使用的版本不完全匹配,可能會導致鏈接器錯誤或崩潰。