Oliver
Oliver

Reputation: 71

OpenCV 2.4.3 on Xcode 4.5

I'm trying to compile a project that uses opencv using xcode 4.5 on Mountain Lion 10.8, I followed closely the procedure on this link:

Compile OpenCV (2.3.1+) for OS X Lion / Mountain Lion with Xcode

This is the sequence that I have followed;

Every time I try to compile xcode fail with this error:

In file included from /Users/oliver/OpenCVHelloWorld/main.cpp:12:
In file included from /opt/local/include/opencv2/opencv.hpp:46:
In file included from /opt/local/include/opencv2/core/core_c.h:47:
/opt/local/include/opencv2/core/types_c.h:322:17: error: use of undeclared identifier 'lrint'
    return (int)lrint(value);
                ^
/opt/local/include/opencv2/core/types_c.h:742:5: error: use of undeclared identifier 'assert'
    assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F );
    ^
/opt/local/include/opencv2/core/types_c.h:773:5: error: use of undeclared identifier 'assert'
    assert( (unsigned)row < (unsigned)mat->rows &&
    ^
/opt/local/include/opencv2/core/types_c.h:780:9: error: use of undeclared identifier 'assert'
        assert( type == CV_64FC1 );
        ^
/opt/local/include/opencv2/core/types_c.h:790:5: error: use of undeclared identifier 'assert'
    assert( (unsigned)row < (unsigned)mat->rows &&
    ^
/opt/local/include/opencv2/core/types_c.h:797:9: error: use of undeclared identifier 'assert'
        assert( type == CV_64FC1 );
        ^
In file included from /Users/oliver/OpenCVHelloWorld/main.cpp:12:
In file included from /opt/local/include/opencv2/opencv.hpp:46:
/opt/local/include/opencv2/core/core_c.h:1118:5: error: use of undeclared identifier 'assert'
    assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ );
    ^
In file included from /Users/oliver/OpenCVHelloWorld/main.cpp:12:
In file included from /opt/local/include/opencv2/opencv.hpp:47:
In file included from /opt/local/include/opencv2/core/core.hpp:56:
In file included from /usr/include/c++/4.2.1/algorithm:64:
In file included from /usr/include/c++/4.2.1/bits/stl_algobase.h:70:
In file included from /usr/include/c++/4.2.1/iosfwd:44:
/usr/include/c++/4.2.1/bits/c++locale.h:76:5: error: use of undeclared identifier 'va_start'
    va_start(__args, __fmt);
    ^
/usr/include/c++/4.2.1/bits/c++locale.h:84:5: error: use of undeclared identifier 'va_end'
    va_end(__args);
    ^
/usr/include/c++/4.2.1/cstdarg:54:20: note: expanded from macro 'va_end'
#define va_end(ap) va_end (ap)
                   ^
In file included from /Users/oliver/OpenCVHelloWorld/main.cpp:12:
In file included from /opt/local/include/opencv2/opencv.hpp:47:
In file included from /opt/local/include/opencv2/core/core.hpp:56:
In file included from /usr/include/c++/4.2.1/algorithm:64:
In file included from /usr/include/c++/4.2.1/bits/stl_algobase.h:70:
In file included from /usr/include/c++/4.2.1/iosfwd:48:
In file included from /usr/include/c++/4.2.1/bits/postypes.h:45:
In file included from /usr/include/c++/4.2.1/cwchar:51:
/usr/include/c++/4.2.1/ctime:65:11: error: no member named 'clock_t' in the global namespace
  using ::clock_t;
        ~~^
/usr/include/c++/4.2.1/ctime:67:11: error: no member named 'tm' in the global namespace
  using ::tm;
        ~~^
/usr/include/c++/4.2.1/ctime:69:11: error: no member named 'clock' in the global namespace
  using ::clock;
        ~~^
/usr/include/c++/4.2.1/ctime:70:11: error: no member named 'difftime' in the global namespace
  using ::difftime;
        ~~^
/usr/include/c++/4.2.1/ctime:71:11: error: no member named 'mktime' in the global namespace
  using ::mktime;
        ~~^
/usr/include/c++/4.2.1/ctime:72:11: error: no member named 'time' in the global namespace
  using ::time;
        ~~^
/usr/include/c++/4.2.1/ctime:73:11: error: no member named 'asctime' in the global namespace
  using ::asctime;
        ~~^
/usr/include/c++/4.2.1/ctime:74:11: error: no member named 'ctime' in the global namespace
  using ::ctime;
        ~~^
/usr/include/c++/4.2.1/ctime:75:11: error: no member named 'gmtime' in the global namespace
  using ::gmtime;
        ~~^
/usr/include/c++/4.2.1/ctime:76:11: error: no member named 'localtime' in the global namespace
  using ::localtime;
        ~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

I Tried also to change compiler to LLVM GCC 4.2 compiler with no luck. Someone can 'tell me the exact steps to build projects on xcode using opencv Mountain Lion and Xcode 4.5?

Upvotes: 3

Views: 4069

Answers (3)

e-y
e-y

Reputation: 21

Without access to your code, I can't say whether this would be a complete fix but, in order to to resolve your "no member named..." compilation errors, you might try substituting "/opt/local/lib" for "/opt/local/lib/**" by double clicking on the "Header Search Paths" field and selecting the "non-recursive" option under XCode's "Build Settings" > "Search Paths" > "Header Search Paths".

You could also try recompiling after navigating to "Build Settings" > "Apple LLVM compiler 4.2 - Language" > "C++ Standard Library", and selecting "libstdc++ (GNU C++ standard library)" rather than XCode 4.5's default "libc++ (LLVM C++ standard library with C++11 support)".

Upvotes: 2

Barney Szabolcs
Barney Szabolcs

Reputation: 12514

I would use a different installing command:

sudo port install tbb
sudo port install opencv +debug +eigen +python27 +qt4 +tbb 

eigen and qt4 is optional, tbb is rather essential, since opencv uses tbb massively for multithreading when present. In other words, opencv is much slower without tbb.

I would not manually specify the compiler. As I remember that did not work for me.

Upvotes: 1

Daij-Djan
Daij-Djan

Reputation: 50089

make sure its compiled as c++, rename your m files to mm

Upvotes: 0

Related Questions