Fixing linking errors caused by MacPorts’ incompatible binaries

I was recently compiling SFML, to see whether it would be a viable replacement for SDL in Plinth, when I came across the following error:

ld: warning: in /opt/local/lib/libfreetype.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

What this means is that I needed libfreetype, but the version installed by MacPorts (into /opt/local/lib, was a 32-bit version).
This is particularly odd, because I was on a 64-bit mac, and I don’t really need 32-bit libraries. Apparently, certain packages in MacPorts don’t get the memo and install only i386 binary libraries anyway.

Upon googling, I saw a lot of people encountering these errors during mac compilation, with all sorts of weird solutions. In many of these cases, the quick fix is simply to tell MacPorts to install all binary versions of the library. This takes up a bit of extra space, since you’ll get other versions of the library for other platforms that you don’t need, but it includes the 64-bit libraries that you do need.

To do this, simply tell MacPorts to install your package with the +universal argument:

$ sudo port install freetype +universal

Voila, linking errors begone.

This entry was posted in Linux, Plinth, Projects and tagged .

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>