Building OpenCV as a macOS Universal Intel Binary

OpenCV

So, for my project, I needed an Intel Universal build of the OpenCV library.

The copy of the OpenCV source I have on my machine is version 3.0.0 and it has worked well for me, so I’ll start with that.

My build machine is running macOS 10.12 and has Xcode 8 installed on it.

OpenCV uses cmake for its build system, so you have to download and install the CMake app for macOS. I got my copy from https://cmake.org

I referred to the article listed on Wired Watershed to help me get started.

I made the following changes to the project once CMake.app was done processing the source folder.

  • Set CMAKE_OSX_ARCHITECTURES value to $(ARCHS_STANDARD_32_64_BIT)
  • Set CMAKE_OSX_DEPLOYMENT to 10.8, since my project needed it.
  • Unchecked 1394

However, when the 32-bit portion of the project went to build, it reported the following error: cap_qtkit.mm:46:9: fatal error: ‘QTKit/QTKit.h’ file not found.

Apparently, this is a known issue.

So, I thought I could solve this problem by going to version 3.2.0… off to GitHub

I cloned the master branch to my machine and ran CMake again on the new source, but when I build the project with Xcode 8, I saw other problems.

So..

  • I unchecked WITH_LAPACK
  • I had to go into the Xcode project and set the C version to c11, and the C++ version to c++14.

Ok, things are getting better, but… the code doesn’t compile for 32-bit.

Dangit!

This can be fixed by … fixing the code?

Off to GitHub again, where I forked the OpenCV project and fixed the Obj-C++ code so that it will build for 32-bit Intel.

With that done, I create a pull request.

If you would like your own copy of the code I modified, you can clone the forked OpenCV repo.

Leave a Reply

Your email address will not be published. Required fields are marked *