2012-12-18 65 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模板时有点不好,如果您的标准库或编译器标志版本与编译时使用的版本不完全匹配,可能会导致链接器错误或崩溃。