1

在 OpenCV 中使用时,我一直在与构建错误作斗争Features2D,我不知道为什么。

  • OpenCV 版本:2.4.3 (MacPorts)
  • 编译arch: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);
4

1 回答 1

3

您是否尝试过在项目设置中删除_GLIBCXX_DEBUG=1和/或_GLIBCXX_DEBUG_PEDANTIC=1从预处理器标志中删除?opencv2 c++ api 在 API 函数中使用 STL 模板有些糟糕,如果您的标准库版本或编译器标志与编译时使用的版本不完全匹配,这可能会导致链接器错误或崩溃。

于 2012-12-18T13:05:27.970 回答