Compile libffi under OSX (10.10 / Yosemite)

Sometimes when playing around and compiling stuff you can mess up your system badly.

In this case I was compiling libffi on my OSX 10.10 system without knowing that other Apps were linking to it – especially Adobe Acrobat Reader (but it seems as Skype is also depending on it). Unfortunately it is linking to a 32bit version of that library and thus crashing on startup.

Libffi is distributed by Apple/OSX directly, so it won’t help to re-install Adobe Acrobat Reader or Skype, instead you will just have to recompile it!

I would not consider it a common problem as most MacBook users do not even know what a terminal is, but just in case, here are the steps to create a fat file (e.g. universal binary supporting 32bit and 64bit architecture) of libffi for your OSX 10.10 (Yosemite) system:

Download libffi and prepare

$ wget ftp://sourceware.org/pub/libffi/libffi-3.1.tar.gz 
$ tar xvfz libffi-3.1.tar.gz
$ cd libffi-3.1
$ rm -rf ~/libffi
$ mkdir -p ~/libffi/32 ~/libffi/64

Compile libffi as 32bit

$ make clean
$ CXXFLAGS=-m64 CFLAGS=-m64 LDFLAGS=-m64 ./configure --prefix=/usr --build=x86_64-apple-darwin14.0.0
$ make
$ cp x86_64-apple-darwin14.0.0/.libs/* ~/libffi/64

Create Fat File/Lib aka “Universal Binary” and Install (poor mans version)

$ lipo -create ~/libffi/{32,64}/libffi.a -output /usr/lib/libffi.a
$ lipo -create ~/libffi/{32,64}/libffi.6.dylib -output /usr/lib/libffi.6.dylib
$ ln -s /usr/lib/libffi.6.dylib /usr/lib/libffi.dylib

All done! Now go enjoy your working system again… oh of course you could also use macports, I guess..


Leave a Reply

Your email address will not be published. Required fields are marked *