Using Gfortran on OSX Snow Leopard to create 32 and 64 bit executables
This recipe covers setting up installing gfortran on OSX Snow Leopard on a 64 bit machine, like most modern hardware, and using it to generate applications that can run on either 32 or 64 bit Intel.
Precondition: MacPorts should be installed.
1. Check that the universal MacPorts variants are set up for both Intel architectures.
cd /opt/local/etc/macports
cat macports.conf
# Check that the universal_archs line looks like this:
universal_archs x86_64 i386
2. Install gcc45 with Macports using the universal variant.
sudo port install gcc45 +universal
This step takes about 2 hours on a recent MacBook Pro.
3. Create a fortran test program called t.f:
write (*,*) 'hello'
end
4. Build it for 32 bit:
gfortran -m32 t.f
$ file a.out
a.out: Mach-O executable i386
5. And for 64 bit:
gfortran t.f
$ file a.out
a.out: Mach-O 64-bit executable x86_64
