How To Compile OpenCV based programs on Mac OS/X

How to compile C on OS/X ?

For Bash:

For csh:

How to compile and link the sample code on OS/X ?

You can compile and run the sample code from the directory it's installed in (usually /usr/local/share/opencv/samples/c):

g++ -bind_at_load `pkg-config --cflags opencv` morphology.c -o morphology `pkg-config --libs opencv`
./morphology

Using gcc in OS X

I am using OS X 10.5.7. The gcc command I use successfully is:

gcc -o foo foo.c -I/usr/local/include/opencv -L/usr/local/lib -lcxcore -lcv -lml -lhighgui -lcvaux

You probably don't need all of the "-lcxcore -lcv -lml -lhighgui -lcvaux" in the command line. Just the libs that you need to link.

OpenCVWiki: CompileOpenCVUsingMacOSX (last edited 2009-07-22 15:09:09 by dwaynephillips)