Thursday, December 12, 2013

Building 32-bit ports on 64-bit Mac OS X using Macports

I a big fan of C# and I also happen to be a Mac OS X user. I wanted to build some project that uses EmguCV on Monodevelop. EmguCV is the C# wrapper for the OpenCV library.

Mono is currently 32-bit only so I tried to build OpenCV in 32-bit as well. It turns out OpenCV needs to link to ffmpeg which was built as a 64-bit library by Macports. I got the following error during linking:

ld: warning: ignoring file /opt/local/lib/libavcodec.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libavcodec.dylib
After some messing around and reading on Macports documentation, it turns out you can build universal packages (by default universal = i386 + x86_64 but you can change it in macports.conf) by adding one parameter to the port command:
sudo port install ffmpeg +universal
 This rebuilt ffmpeg to include both x86_64 and i386 and solved my problem.

Hope this helps someone else out there.

No comments:

Post a Comment