I would like to use OpenFrameworks for an OSX application I am building. However, I need to include some existing code that uses C++ OpenCV commands, e.g. cv::imread().
The Xcode linker throws the error Undefined symbols for architecture i386: "cv::imread(std::string const&, int)
. At first I tried to use the existing OpenCV code that is in ofxOpenCv, then fell back to including the OpenCV framework as I had in previous non-OpenFrameworks projects. Neither approach solved the linking problem.
As far as I can tell, the problem is that OpenCV is compiled with the libc++ compiler, while OpenFrameworks is compiled with the libstdc++ compiler.
- This presentation shows how to use C++ OpenCV commands within OpenFrameworks, but it is under Windows and not a detailed account.
- This SO Question implies that OpenCV can be recompiled under libstdc++, but the solution given is for iOS and referenced make file does not exist for OSX/linux.
Is it at all possible to use OpenFrameworks with the OpenCV C++ commands under OSX?
Please use Kyle McDonald's ofxCv addon, it's a much nicer interface to opencv from openframeworks. It includes Utilities to convert from
cv::Mat
of ofImage and back for example or helpers to drawcv::Mat
straight in your of application:Also, your
Undefined symbols for architecture i386:
error means you probably linked against the x64(64-bit) opencv .dylib files, not the i386(32b-bit) ones.