Powered by Blogger.

Tuesday, September 8, 2009


Compile Opencv with Mac os Snow Leopard 10.6

Today i try install OpenCv in my MacOs Snow Leopard 10.6 and have this error:

error: CPU you selected does not support x86-64 instruction set

The searching in google have the solution

go to opencv folder and edit configure file, searchi prescott and replace the line

DEFAULT_CXXFLAGS="-g -march=prescott -ffast-math -fomit-frame-pointer $DEFAULT_CXXFLAGS"

with this:

DEFAULT_CXXFLAGS="-g -march=i686 -m32 -ffast-math -fomit-frame-pointer $DEFAULT_CXXFLAGS"

But when i try to compile i have other error i now looking for how to resolve it

Now i can install opencv lib with macport!!!

1.- i have old macport then first i need clean and delete it.
port installed > myports.txt

sudo port clean installed

sudo port -f uninstall installed

2.- Install ports you need you can see myports.txt to know the old ports you have installed before clean.

3.- Patch the opencv port: see http://trac.macports.org/ticket/21014 and download the patch Portfile-sl_64bit_21014.diff

4.- Follow the instruction in post of patch
Check where you installed macports, that is usually /opt/local/ Locate the Portfile for OpenCV, for me that is at


now apply the third patch (Portfile-sl_64bit_21014.diff) by executing

sudo patch Portfile -i ~/Downloads/Portfile-sl_64bit_21014.diff

in the above directory (adjust the last path accordingly to your download location)

When you execute port variants opencv you should see the sl_64bit_21014 variant. Now install opencv with

sudo port install opencv +sl_64bit_21014

About David Millán Escrivá

David completed his studies in Universidad Politecnica de Valencia in IT with a Master's degree in artificial intelligence, computer graphics, and pattern recognition, focusing on pattern recognition and Computer Vision. David has more than 15 years of experience in IT, with more than ten years of experience in Computer Vision, computer graphics, and pattern recognition, working on different projects and start-ups, applying his knowledge of Computer Vision, optical character recognition, and augmented reality. Co-Author of two OpenCV books and reviewer of few more.


  1. Thanks Morton for your comment, of course i run opencv with X11 and without quicktime. There are a lot of things to correct for totally support of opencv in mac os snow leopard.

    Regards. David.

  2. [...] Compile Opencv with Mac os Snow Leopard 10.6の記事からバッチファイルを取得 wget [...]

  3. [...] Mac os Snow Leopard 10.6 October 29, 2009 lgustavomartins Leave a comment Go to comments Compile Opencv with Mac os Snow Leopard 10.6. Categories: Development, Mac Tags: compile, openCV, Snow Leopard Comments (0) Trackbacks [...]

  4. En castellano.
    Poseo un PowerMac G5y estoy empezando con esto del OpenCV. En vez de instalarlo desde el código fuente tienes la opción de instalar el framework que esta en esta dirección: http://vislab.cs.vt.edu/~vislab/wiki/images/4/44/OpenCV2.0.dmg
    SEgun he notado probando códigos. La única peculiaridad es que compilando desde Terminal hay que usar g++ y no gcc para que compile bien, aunque lo hagas sobre ficheros de c.
    La instalación del framework es trivial y supongo que su uso con Xcode será muy sencillo, no lo he probado porque estoy acostumbrado a compilar desde terminal.
    Comentar que para que compile hay que cambiar las cabeceras incluidas en los ficheros por #include .
    Por cierto, excelentes artículos y espero ansioso tu artículo sobre substracción del fondo de forma avanzada.

    P.D. También tengo un portatil con Snow Leopard, pero todavía no he instalado OpenCV, si tienes cualquier duda dimelo y lo pruebo.

  5. I read and comment on a blog with the aid of an interpreter so I apologize for the sloppy. I sincerely wish to continue to write articles in a similar vein, that was more valuable information for people.

  6. good article.congratulations:) gregor-----www.seocat.dixads.com

  7. Thank you for the good writeup. It actually was once a enjoyment account it. Look advanced to far added agreeable from you! By the way, how could we communicate?

  8. I do not even know how I ended up here, but I thought this post was good.

    I do not know who you are but definitely you are going to a famous blogger if you aren't already ;) Cheers!

  9. Hi, I do believe this is an excellent blog.
    I stumbledupon it ;) I'm going to return once again
    since I saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to help
    other people.

  10. Lߋs ɑrticulos me gսѕtaron alvo mas...


  11. You're not extremely the evaluation points with the women by carrying that tatty, recent light brewage shirt that you simply won after you were in school My pair of them have only worn quite slightly since I bought them, and they look nearly the same

  12. You should take part in a contest for one of the greatest
    websites on the web. I am going to highly recommend this blog!

  13. Hi Dear, are you genuinely visiting this web page regularly, if so after that you will definitely obtain good experience.

  14. I've learn several just right stuff here. Definitely price bookmarking for revisiting.
    I wonder how so much attempt you set to make such a fantastic informative web site.