在 OpenCV 中使用 Features2D
时,我一直在与构建错误作斗争,我不知道为什么。
- 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);
最佳答案
您是否尝试过从项目设置的预处理器标志中删除 _GLIBCXX_DEBUG=1
和/或 _GLIBCXX_DEBUG_PEDANTIC=1
? opencv2 c++ api 在 API 函数中使用 STL 模板时有些糟糕,如果您的标准库版本或编译器标志与编译时使用的版本不完全匹配,这可能会导致链接器错误或崩溃。
关于c++ - 在带有 XCode 的 OpenCV 中使用 Featured2D 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13933513/