Build error using Featured2D in OpenCV with XCode-Collection of common programming errors

I have been fighting with an build error when using Features2D in OpenCV which i cannot figure out why.

  • OpenCV version: 2.4.3 (MacPorts)
  • Compile arch: 64-bit intel
  • C Language Dialect: GNU99
  • C++ Language Dialect: GNU++11
  • C++ Standard Library: libstdc++

The build error:

Undefined symbols for architecture x86_64:
"cv::FeatureDetector::detect(cv::Mat const&, std::__debug::vector&, cv::Mat const&) const", referenced from:
  analysis::openCvStitching() in analysis.o
"cv::DescriptorMatcher::match(cv::Mat const&, cv::Mat const&, std::__debug::vector&, cv::Mat const&) const", referenced from:
  analysis::openCvStitching() in analysis.o
"cv::DescriptorExtractor::compute(cv::Mat const&, std::__debug::vector&, 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)

This is how i create a pointer to the FeatureDetector and DescriptorExtractor:

Ptr surfDetector = FeatureDetector::create(type);
Ptr surfExtractor = DescriptorExtractor::create(type);
  1. Have you tried deleting _GLIBCXX_DEBUG=1 and/or _GLIBCXX_DEBUG_PEDANTIC=1 from the preprocessor flags in your project settings? opencv2 c++ api is somewhat bad in its use of STL templates in the API functions, which may cause linker errors or crashes if your version of the standard libraries or compiler flags do not match exactly with what’s used when it was compiled.

Originally posted 2013-11-06 03:08:11.