我正在尝试在 Mountain Lion 10.8 上使用 xcode 4.5 编译一个使用 opencv 的项目,我密切关注此链接上的过程:
使用 Xcode 为 OS X Lion / Mountain Lion 编译 OpenCV (2.3.1+)
这是我遵循的顺序;
- 使用端口安装opencv:sudo port install opencv configure.compiler = llvm-gcc-4.2
- 打开 Xcode 并创建一个新项目(使用 c++ 的命令行应用程序)。
- 在“库搜索路径”中添加了“/opt/local/lib/**”路径
- 添加了任何 libopencv_。Dylib 到一个新组
- 在“标头搜索路径”中添加了“/opt/local/include/**”路径
每次我尝试编译 xcode 时都会出现以下错误:
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.
我还尝试将编译器更改为 LLVM GCC 4.2 编译器,但没有成功。有人可以告诉我使用 opencv Mountain Lion 和 Xcode 4.5 在 xcode 上构建项目的确切步骤吗?