OpenCV library not installing after using cmake

I use Yosemite 10.10, and I need to build and install the OpenCV library using cmake-gui. I was able to configure and generate the binaries readily. But when I try to 'make' the library using the terminal sudo make -j4 in the binaries folder, I get the following error -

Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.o
In file included from /usr/include/os/object.h:27:0,
             from /usr/include/dispatch/dispatch.h:48,
             from /Users/imecindia/Desktop/Downloaded Libraries/opencv-3.0.0-beta/modules/core/src/parallel.cpp:106:
/usr/include/os/base.h:113:20: error: missing binary operator before token "("
#if __has_extension(attribute_overloadable)
                ^
/usr/include/os/base.h:119:54: error: missing binary operator before token "("
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
                                                  ^
[ 45%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/pca.cpp.o
In file included from /usr/include/dispatch/dispatch.h:51:0,
             from /Users/imecindia/Desktop/Downloaded Libraries/opencv-3.0.0-beta/modules/core/src/parallel.cpp:106:
/usr/include/dispatch/object.h:325:20: error: missing binary operator before token "("
#if __has_extension(c_generic_selections)
                ^
/usr/include/dispatch/object.h:363:20: error: missing binary operator before token "("
#if __has_extension(c_generic_selections)
                ^
/usr/include/dispatch/object.h:391:20: error: missing binary operator before token "("
#if __has_extension(c_generic_selections)
                ^
/usr/include/dispatch/object.h:423:20: error: missing binary operator before token "("
#if __has_extension(c_generic_selections)
                ^
/usr/include/dispatch/object.h:143:15: error: expected unqualified-id before '^' token
typedef void (^dispatch_block_t)(void);
           ^
/usr/include/dispatch/object.h:143:15: error: expected ')' before '^' token
/usr/include/dispatch/object.h:362:3: error: 'dispatch_block_t' has not been declared
dispatch_block_t notification_block);
^
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2

I get that in multiple places in this particular file,

Also I specified the compiler for using gcc/g++/gfortran that came with MacPorts. It's mandatory that I use the MacPorts compiler btw.

Can someone let me know what I can do?


I'm sorry but I could fix it myself. In Cmake GUI WITH, I just enabled WITH_OPENMP.

I'm leaving this question here though just in case someone else faces the same issue later on.


I'll add another answer, piggybacking on yours, but in the case that someone isn't using the cmake gui. In this case, If you want to enable WITH_OPENMP look in opencv-2.4.10/CMakeLists.txt. Search for OpenMP and edit this line and change OFF to ON.

OCV_OPTION(WITH_OPENMP         "Include OpenMP support"                      ON)