Building OpenCV on Mac OS Sierra

I struggled to build OpenCV on Mac OS Sierra because a package called QTKit has been deprecated since 10.9. Apparently the solution was to use AVFoundation (which I discovered while looking at the OpenCV repo).

Here is the solution to building OpenCV without any issues.

Building the static libraries
  • First of all, download and install CMake
  • Secondly download and unzip the latest build of OpenCV from the github page instead of the official website
  • Start CMake and set the source directory to your newly extracted OpenCV folder
  • Inside the OpenCV folder, make two directories called "staticlibs" and sharedlibs"
  • Inside CMake set the build path to the "staticlibs" you just created.
  • Click on the configure button at the bottom
  • Make sure "Unix Makefiles" is selected in the dropdown, leave everything else default and click the done button. This might take a few moments before the list of modules pops up in red in CMake.
  • Deselect the following values: BUILDSHAREDLIBS, BUILDTESTS, WITH1394, WITH_FFMPEG
  • Ensure CMAKEOSXARCHITECTURES is set to "x86_64" (excluding the quotation marks)
  • Click configure again and lastly click generate
  • Open Terminal and type in the following commands:
cd [path-to-your-opencv-staticlibs-folder]  
make  
  • Wait for the make command to finished (you'll see a percentage indicated during the build). Once it is done you'll want to install these static libraries onto your computer by typing in the following command in terminal (you'll be asked to enter in your system password):
sudo make install  
Building the shared libraries
  • Go back into CMake, make sure your source directory is still the OpenCV folder and update the build path to the shared libraries folder
  • Click the configure button and make sure "Unix makefiles" is selected and click the done button
  • Once the list of red items pops up deselect the following items: BUILDTESTS, WITH1394, WITH_FFMPEG.
  • Make sure BUILDSHAREDLIBS is checked
  • Make sure CMAKEOSXARCHITECTURES is set to x86_64
  • Click configure again and then generate
  • You will need to open terminal again and follow the same make commands as listed above: "make", followed by "sudo make install" when you are inside the "sharedlibs" folder
  • The shared libraries will then be installed on your computer

You can now start using OpenCV!

I usually work in Xcode when I'm on Mac. I'll upload a short "Hello World" tutorial for OpenCV in the next few days.

Happy coding!

You might enjoy:

Next post No more posts

Comments

comments powered by Disqus