Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

###Download XCode from the App Store Get it from here

###Get cmake Use/get a package manager, such as homebrew. Open a terminal window and type the following

brew install cmake

This will get the required packages for cmake.

###Get and install OpenCV

  • Download the latest OpenCV for Linux/Mac
  • Navigate to location of downloaded file and untar it with the following command
tar xvzf opencv-
  • Navigate to extracted folder cd path/to/folder
  • Create a build directory and build opencv with the following commands
mkdir build
cd build
cmake -G "Unix Makefiles"...
  • Make and install
make -j8
sudo make install

###Set up an OpenCV project in XCode

  • Start XCode

  • Create new "Command Line Tool" project with type C++ screenshot

  • Add OpenCV to your project

    • Right click your project on the sidebar, select "Add files to..." screenshot
    • When the file chooser dialog opens up, press cmd + shift + G and enter "/usr/local/lib" screenshot
    • Select the required OpenCV files (named in the format libopencv_*.dylib), or select all. Press Add or Return screenshot
    • You will see that all selected files are now in the sidebar. You can youp them together by creating a new Group and dragging the files in there. screenshot
  • Configure your project

    • Click on the project (in the side bar), and you should see the Project settings come up in the middle of the editor
    • Click the All view (top left corner)
    • In the search bar type "Header Search Paths", double click the value, remove the existing entries and add /usr/local/lib and /usr/local/include screenshot
    • Now search for "Library Search Paths" and replace the values with /usr/local/lib
    • Search for "C++ Standard Library" and select "libstdc++ (GNU C++ Standard Library)" screenshot
  • Try the configuration

    • Run one of the sample OpenCV projects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment