0

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
Dai
  • 141,631
  • 28
  • 261
  • 374
  • What happens when you try to build a really stupid file that's just `#include ` and `int main(){return 0;}`? – user4581301 Feb 02 '16 at 03:55
  • Without your `main.cpp`, its hard to tell where the error was. First thing I would do is to try `using namespace std;` – Quang Hoang Feb 02 '16 at 04:02
  • @user4581301 I have updated my question – Dai Feb 04 '16 at 20:17
  • @QuangHoang I have updated my question – Dai Feb 04 '16 at 20:18
  • I ask again, because this will help tell if this is an inclusion order problem in Open CV or an error on your compiler configuration, what happens when you compile `include int main(){return 0;}`? Do you get the same set of errors? If not, I'd start walking back up the include trace until it breaks. Won't solve the problem, but it will reduce the problem area. – user4581301 Feb 04 '16 at 20:46
  • Any reason not to use `homebrew`? It's the simplest way on OSX... http://stackoverflow.com/a/24985811/2836621 – Mark Setchell Feb 04 '16 at 20:50
  • @user4581301 When I build the code( `#include ...`) it builds successfully. – Dai Feb 04 '16 at 20:56
  • @MarkSetchell I have re-installed OpenCV using homebrew. I set my Project Header search path to `/usr/local/include/**` (the `opencv2` directory is within) but I still get the same 20 errors about `memcpy`. – Dai Feb 04 '16 at 21:20
  • Have you looked at the red and blue boxes marked in this post? http://stackoverflow.com/a/34341219/2836621 – Mark Setchell Feb 04 '16 at 21:34

0 Answers0