How I made Open-Cv working with XCode on my mac

After many frustrating attempts I finally made OpenCv works on my mac.

Here I’ll explain how:

1) Install CMake  ( ) by just flowing the installer assistant

2)Download OpenCv (

3)Execute the followings instruction in your Terminal (/Applications/Utilities/Terminal)

cd /path to your download folder
tar xvf OpenCV-your version.tar.bz2
cd OpenCV-your version
mkdir build
cd build
cmake -G "Unix Makefiles" ..
sudo make install

4) Now under /usr/local/lib you should have some new files beginning with OpenCV





5) Now create a new XCode project


6) Now your project is create you can add the library we just download under “Build Phases”


6) Link the binaries by cliking “+” then “Add Other…” . A window pop-up, then strike “/” for me it was “shift-7” (in Switzerland) and type /usr/local/lib . The select opencv core & highgui which are the two most important library to have.


7) Now you should have the to library on the left bar, you can put the files into a seperate folder to make your project cleaner if you want.


8) Finally under “Build Settings” search for the “Search Paths” section and modify the entries as shown below.






42) The last step is to learn OpenCv.

Here is a template I always start with this make the include much easier.

// main.cpp

#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
CvCapture *capture;
IplImage *img;

int key;

capture = cvCreateCameraCapture(CV_CAP_ANY);
cvNamedWindow( "First Code", 1 );

while( key != 'q' )

img= cvQueryFrame( capture );
cvShowImage( "First Code", img);
key = cvWaitKey( 10 );


cvReleaseCapture( &capture );
cvDestroyWindow( "First code" );

return 0;

It just return the input of your webcam 🙂

Good Luck. And catch you next time.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s