Ask Your Question

tigakub's profile - activity

2018-09-15 12:33:48 -0600 received badge  Popular Question (source)
2013-12-21 14:02:44 -0600 received badge  Student (source)
2013-12-19 19:19:41 -0600 asked a question Undefined symbols cv::_OutputArray::_OutputArray(std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >&)

Hi everyone. I've been trying to incorporate OpenCV into a Kinect project I have going on OS X Mountain Lion (Xcode 4.6, OpenCV 2.4.7).

Everything seemed to be going fine until I tried calling cv::calibrateCamera, which seems to require output args of class OutputArrayOfArrays. In the examples I see that references to std::vector<cv::mat> are passed in. The code compiles fine, but fails on the link with the following error:

Undefined symbols for architecture x86_64:  
  "cv::_OutputArray::_OutputArray(std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >&)"

I've read that such errors might be because of a discrepancy between the c++ library against which the opencv libraries are linked and that against which the app code is linked. I've tried switching to libstdc++ in Xcode, and that seems to generate a whole slew of other errors which lead me to think that opencv 2.4.7 was updated with c++11 in mind?

So, just in case, I went back and reconfigured the opencv build with the following.

cmake -D CMAKE_CXX_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -D CMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" -D LLVM_ENABLE_CXX11=ON -D CMAKE_SHARED_LINKER_FLAGS="-lc++"

Unfortunately, I'm still getting the linker error. I don't think it's because I'm missing a library because this is a template invocation, so the code is generated at compile time, no? The code that seems to be causing the problem is as follows.

vector<cv::Mat> rVecs, tVecs;
double tResult = cv::calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rVecs, tVecs, flag);

Is there something wrong with my syntax? Am I missing some kind of typename qualifier or something?

I've been banging my head against this for a couple of days now and would deeply appreciate any insight anyone may have.

Thanks!