Monday, February 09, 2015

OpenCV 2.4.10 and Macports

Every time I've needed to build OpenCV on my work Mac, it's been a bit of a struggle. I have Macports installed which helps make some things easier, but throws up problems of its own:
(using "mp-gcc49")
/Users/oisin/Documents/code/vision/opencv-2.4.10/modules/highgui/src/ In function 'void cvDestroyAllWindows()':
/Users/oisin/Documents/code/vision/opencv-2.4.10/modules/highgui/src/ error: expected ';' before 'in'
     for(NSString *key in list) {

(using "apple-gcc42")
/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;
/System/Library/Frameworks/QTKit.framework/Headers/QTMovieModernizer.h:123:46: error: expected identifier before '(' token

The problem appears to be Objective-C stuff in QTKit and in OpenCV's HighGUI code. This time, the solution was to revert to the system-default C/C++ compiler, Clang:
$ sudo port select gcc none
Warning: port definitions are more than two weeks old, consider updating them by running 'port selfupdate'.
Selecting 'none' for 'gcc' succeeded. 'none' is now active.

It's slightly counterintuitive that "port select gcc none" is how you go back to the system compiler with Macports, and it doesn't appear to be stated in the docs, so... well here it is!