I followed these instructions to install and build OpenCV 3 on my Mac: http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/
I am successfully able to build the sample program (from the command-line) included at the bottom of that article.
I then followed the author's second article here: http://blogs.wcode.org/2014/11/howto-setup-xcode-6-1-to-work-with-opencv-libraries/ - I note that I'm using Xcode 7.2 instead of 6.1, but all of the dialogs and steps seemed to work fine.
...except for building.
With the simple C++ program included in the above article I get these build errors:
Xcode shows 20 errors all coming from cstring.h
of the form:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:70:9: No member named 'memcpy' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:71:9: No member named 'memmove' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:72:9: No member named 'strcpy' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:73:9: No member named 'strncpy' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:74:9: No member named 'strcat' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:75:9: No member named 'strncat' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:76:9: No member named 'memcmp' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:77:9: No member named 'strcmp' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:78:9: No member named 'strncmp' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:79:9: No member named 'strcoll' in the global namespace; did you mean 'strtoll'?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:80:9: No member named 'strxfrm' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:82:9: No member named 'memchr' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:84:9: No member named 'strchr' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:86:9: No member named 'strcspn' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:88:9: No member named 'strpbrk' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:90:9: No member named 'strrchr' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:92:9: No member named 'strspn' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:94:9: No member named 'strstr' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:98:87: No member named 'strchr' in the global namespace; did you mean simply 'strchr'?
It also gave me errors in the main.cpp
file itself:
/Users/me/src/opencv-me-2/OpenCVTest/OpenCVTest/main.cpp:14:14: Invalid operands to binary expression ('ostream' (aka 'int') and 'const char *')
/Users/me/src/opencv-me-2/OpenCVTest/OpenCVTest/main.cpp:29:16: Variable has incomplete type 'string' (aka 'basic_string<char, char_traits<char>, allocator<char> >')
/Users/me/src/opencv-me-2/OpenCVTest/OpenCVTest/main.cpp:30:14: Invalid operands to binary expression ('ostream' (aka 'int') and 'const char *')
/Users/me/src/opencv-me-2/OpenCVTest/OpenCVTest/main.cpp:49:38: No viable conversion from 'cv::Mat' to 'const cv::_InputArray'
/Users/me/src/opencv-me-2/OpenCVTest/OpenCVTest/main.cpp:50:26: Invalid operands to binary expression ('ostream' (aka 'int') and 'const char *')
/Users/me/src/opencv-me-2/OpenCVTest/OpenCVTest/main.cpp:66:17: Variable has incomplete type 'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >')
/Users/me/src/opencv-me-2/OpenCVTest/OpenCVTest/main.cpp:71:14: Invalid operands to binary expression ('ostream' (aka 'int') and 'const char *')
...I was able to eliminate those by adding #include <string>
after the #include <stdio.h>
line. However the "No member named 'memcpy' in the global namespace" errors still persist.
Update
Here is my minimal working example file:
main.cpp#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio/videoio.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace cv;
using namespace std;
int main(int ac, char** av) {
return 0;
}
When I build it, I get the same 20 errors in cstring
- which isn't referenced by my main.cpp
file directly. Xcode reports the include-trace is:
main.cpp:1
opencv2/imgcodecs.hpp:46
opencv2/core.hpp:54
opencv2/core/base.hpp:53
Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:626