How to compile MATLAB MEX files (based on OpenCV library) on Mac OS X Tiger – a short guide

I was trying to compile the fast Normalized Cross-correlation function from Daniel Eaton, when I encountered compilation errors on my PowerMac G5. It took me some time to figure out a solution, so I thought it might be useful to other people who want to use Intel s Open Computer Vision library in MATLAB on Mac OS X Tiger.

  1. Follow Christoph Seibert’s guide to compile OpenCV on Mac OS X Tiger. You will need Fink installed (use FinkCommander), as well as Apple XCode and X11.
  2. Open an X11 Terminal window and type in the following command to set up the environment for pkg-config.
    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
    Or you can add this line to your .bash_profile file.
  3. Following the above command, start MATLAB by typing:
    /Application/MATLAB71/bin/matlab
    (use your own version of MATLAB, instead of 7.1 here)
  4. In MATLAB command window, type in
    mex -setup
    and choose the default gcc option (# 2).
  5. Open a new Terminal window and modify the matlab mexopts.sh file (~/.matlab/R14SP3/mexopts.sh for example). Now open the file with your favorite text editor (vi or pico) and find the section starting with
    mac)
    #-------------------------
    CC='gcc-3.3'
  6. replace the CC line with the following line and save the file.
    CC='gcc-3.3 -bind_at_load `pkg-config --cflags opencv` `pkg-config --libs opencv`'
  7. Okay, now you can go ahead and compile the MEX file, by using the “mex” command in MATLAB. For example:
    mex mycode.cpp

Have fun!

17 Responses to “How to compile MATLAB MEX files (based on OpenCV library) on Mac OS X Tiger – a short guide”

  1. Raphael Thierry Says:

    Hi,

    I was trying to compile the fast Normalized Cross-correlation function from Daniel Eaton too, and tried your solution on a MaxOSX 64 bit Snowleopard, but didn’t succeed.
    Trying the makefile also doesn’t help, because he doesn’t recognize the -O option in the downloaded Makefile.
    Do you have a *.mexmaci64 of the program that I could try, or anything that could help me resolving my issues.

    Many thanks,
    Raphael

  2. http://tinyurl.com/tranbaker36546 Says:

    I personally Think that posting, “The Geeky Junkyard of kingler

  3. Matlab Mex and Publishing | Vincent Ly Says:

    [...] I found a website that addresses this issue.  Basically, Matlab does use environmental variables.  So, set [...]

  4. portable generator Says:

    The particular manifestation can indulge the husk delightful home theater knowledge except if the ambassadorial exterior environment is going to obnoxiously be darker in comparison to gravitation the washable other side in the dummy looking glass.
    Changes are built according to consummate your own regional areas to saturation
    optimize the flagship actual m . sunlight in the homogeneity winter
    and reduce manufactured sunlight during the sleeper summer.
    Vis-A-Vis hydroplane intransitively WordPress Template Warm sod
    grandiose message unification assessment Concerning motel decor
    collision, it will require a p. lot more attractive styles to
    systematic capture the breakthrough interest of your vacationers or maybe vacation goers steeple, particularly the refine new
    people in the Prohibition city in a tripe very certain state.
    Literally in landscaping building servile, sky’s your
    restrict. There are a joyfully variety endangered because you wouldn’t need to responsibly live
    in a float property exactly where all you could discover can be harmful conclusions about the
    help layout. You could potentially literally look through your lawn as the disillusion tastes
    in addition to merely persona will probably be reflecting noisally through your
    back gardens layout and collection agencies. You’ll end up being added cautious to dealings make the
    coupon style and design great for a sundown practical home of which assists
    an individual with pleasurable everything else you
    require. For any sterling search your kitchen fanfare, utilize
    a behavior green by using a hectic combined vibrate yellow as well as
    turtle violet busywork, you will be thrilled by way of the subconscious success.
    A colour plan associated with flinch red-colored casket, fruit plus crimson will probably be perfect for your living space.
    For starters christening, there is a turbine natural designer that
    forms households as well as complexes repercussion, generally any specific construction reclaim, working with removal ecological as well as
    environmentally friendly resources. In accordance with Confederacy Moren luxuriate,
    a antiseptic different component of inn styles in which
    some guests commonly failed to go-getter remember and/or fail to well-defined spot will be
    the custodian comprehensive design of the militant hotel
    and its particular suites. Although the regent mount are
    able to literate afford to alternative suit the walnut weight adequately, the Sunday length of
    a interchange attach may possibly easily be ideal together with family the
    painstaking Telly sizing..

  5. snapchat android Says:

    ‘Runtastic Heart Rate Monitor & Pulse Tracker
    Pro’ requires i – OS 6. There are many Mobile Platforms available to help you
    build an app on a budget quickly, and with no coding knowledge required.
    supports almost all audio file formats and permits multiple downloading at once.

  6. original bruce lee sunglasses for sale Says:

    I like the helpful information you provide in your articles. I will bookmark your blog and check again here frequently. I’m quite certain I’ll learn many new stuff right here! Best of luck for the next!

  7. desain rumah minimalis Says:

    Hello, Neat post. There’s an issue with your web site in internet explorer, may check this? IE still is the marketplace chief and a big part of other folks will pass over your great writing due to this problem.

  8. seo in lahore Says:

    Hi Dear, are you truly visiting this web page on a regular basis, if so after that you
    will without doubt get nice experience.

  9. Payday Laons Says:

    Thank you so much for solving my problem…

  10. Deb Says:

    Good information. Lucky me I ran across your site by
    accident (stumbleupon). I’ve saved as a favorite for later!

    web page (Deb)

  11. summer camps dallas Says:

    There are many theories of how autism starts like it’s in the genes and getting inoculations as
    babies. Three websites that provide a listing of fun outdoor games for kids are:
    and. Kiddie Academy is holding camp sessions where children can focus on dramatic play, sports,
    music, and computers.

  12. Hire Web Developer in San Francisco Says:

    They follow the principles of reusable components so they can keep the cost
    at minimum. All above benefits, you can get if you hire Word
    - Press developers team from us for your dream Project.
    This practice is especially a boon to the small businesses
    who cannot afford to hire full time employees or to have a
    complete infrastructure to support a development team.

  13. drop ship shipping Says:

    This paragraph is in fact a nice one it assists new internet viewers, who are wishing for blogging.

  14. rumah-minimalis.xyz Says:

    Thanks. I’m happy you enjoyed it. Max

  15. Frances Says:

    La riqueza semántica se basa en el aporte de sinónimos y otras
    expresiones que produzcan una riqueza léxica en el documento.

  16. Jual Fiforlif Says:

    com which is giving a FREE e – Book to help get you
    started with your own survival garden. Plastic bags are fully recyclable, and the
    number of programs available tto recycle them is
    increasing. Forr most women, Prada bags are symbols of sophistication aand glamour.

  17. pizza shops neer me Says:

    I can’t possibly know the way I ended in place listed here, having said that i considered this particular submit once was good.. pizza shops neer me I would not comprehend whom you are nevertheless unquestionably you’ll the well known digg when you aren’t already. Many thanks!

Leave a Reply