Tuesday, September 11, 2012

Fixing gcc45 compilation in macports for i386

I normally compile all of macports on Snow Leopard for i386. The main reason is that default wxwidgets 2.8 don't work for 64 bit compiles, and I need them for wxmaxima.

The gcc45 compilation fails with the following error:

checking for the correct version of the gmp/mpfr/mpc libraries... no
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at

Assume we have the following in /opt/local/etc/macports/macports.conf:

build_arch              i386
universal_archs         x86_64 i386

One needs to edit the portfile of gcc45 as follows:

$ sudo port edit gcc45

Then go to the last line of the configure argument list and add
CC="gcc -m32"

Don't forget to add the line continuation backslash on the preceding line!

This fixes compilation of gcc45.