Static libgfortran on OS X

IainS developer@sandoe-acoustics.co.uk
Thu Dec 18 11:06:00 GMT 2008


On 17 Dec 2008, at 15:15, Ray Nachlinger wrote:

> On Wed, 17 Dec 2008, IainS wrote:
>> If that doesn't work, then I'm working on reissuing my patch to  
>> make static
>> libgfortran work on darwin.... but it's not going to be for at  
>> least a few
>> days.
>
>   Thanks, I will wait.

Hm. I think this going to take a little longer (some day-job stuff is  
demanding attention).

A work-around (I'm assuming you're prepared to build gcc, if you were  
going to try my patch... so...).

Apologies if any of the following is "teaching my grandmother"... and  
see also http://gcc.gnu.org/install/

1/ build (or obtain) an up-to-date gcc, including fortran (current  
svn is building OK in my experience).
[[ 1 (a) if you install using fink etc. you can still make the  
changes - but you'll have to find stuff relative to the /sw or /opt  
and sudo the mv/ranlib ]]

use (at least) [assuming you're building this to operate on Leopard] :
--prefix=/somewhere/you/have/rights/to/install/to   (it's not  
necessary to use a privileged path).
--enable-languages=c,fortran  (at least)
--target=powerpc-apple-darwin9 --host=powerpc-apple-darwin9

I recommend:
--enable-version-specific-runtime-libs --enable-checking=release  -- 
program-suffix=-4.4.0

I don't recommend:
  --with-slibdir= ... if you do use it ... be very careful NOT to  
overwrite anything in your /usr/lib directory  - you'll need to do a  
staged install.

2/ once installed and assuming you used the options above...

cd /your/chosen/prefix/lib/gcc/i386-apple-darwin9/4.4.0
mv libgfortran.a libgfortran-static.a
ranlib libgfortran-static.a  (don't worry about the messages)
mv libgomp.a libgomp-static.a
ranlib libgomp-static.a (don't worry about the messages)
cd x86_64
mv libgfortran.a libgfortran-static.a
ranlib libgfortran-static.a  (don't worry about the messages)
mv libgomp.a libgomp-static.a
ranlib libgomp-static.a (don't worry about the messages)

3/  Note that -Bstatic didn't do anything on Apple's linker last time  
I checked... (although they hopefully will add it sometime)

to build a completely static executable:

/your/chosen/prefix/bin/gfortran-4.4.0 -nodefaultlibs <all your  
objects> -o <your output file> -lgfortranbegin -lgfortran-static [- 
lgomp-static] -lgcc_eh -lgcc -lSystem

hth,
Iain



More information about the Fortran mailing list