我正在尝试使用GCC 4.8.2(由brew安装)从Mac OS X 10.9.4中的源代码编译OpenCV 2.4.9但我根本无法构建highgui模块。
默认情况下,它尝试使用Cocoa框架,其标头似乎是Objective C 2,并且无法由GCC解析。我收到这些错误:
[ 20%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_cocoa.mm.o
opencv-2.4.9/modules/highgui/src/window_cocoa.mm: In function 'void cvDestroyAllWindows()':
opencv-2.4.9/modules/highgui/src/window_cocoa.mm:200:23: error: expected ';' before 'in'
for(NSString *key in list) {
我尝试使用Qt 4.8.6(由brew安装)并在cmake中激活WITH_QT
。我想我遇到了和上面相同的问题。我明白了:
[ 27%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_qtkit.mm.o
In file included from /System/Library/Frameworks/QTKit.framework/Headers/QTKit.h:51:0,
from opencv-2.4.9/modules/highgui/src/cap_qtkit.mm:46:
/System/Library/Frameworks/QTKit.framework/Headers/QTMovieModernizer.h:123:46: error: expected ')' before '(' token
- (void)modernizeWithCompletionHandler:(void (^)(void))handler AVAILABLE_QTKIT_VERSION_7_7_3_AND_LATER;
^
最后,我尝试使用Carbon激活WITH_CARBON
,这应该可以在Mac上使用。我得到了这样的几个错误:
opencv-2.4.9/modules/highgui/src/window_carbon.cpp: In function 'void icvDrawImage(CvWindow*)':
opencv-2.4.9/modules/highgui/src/window_carbon.cpp:227:54: error: 'GetWindowPortBounds' was not declared in this scope
GetWindowPortBounds(window->window, &portrect);
^
有什么方法可以在不退回Clang的情况下构建highgui?