From: Martin Costabel <costabel@wanadoo.fr>
To: Norman Gray <norman@astro.gla.ac.uk>
Cc: fortran-dev@lists.apple.com
Subject: Re: Link problems: restFP/saveFP and -lcc_dynamic -- why?
Date: Tue, 27 Jul 2004 15:18:24 +0200
Message-ID: <41065620.1070001@wanadoo.fr>
References: <Pine.LNX.4.58.0407271319070.26008@ptolemy>
In-Reply-To: <Pine.LNX.4.58.0407271319070.26008@ptolemy>

Norman Gray wrote:
> Greetings,
> 
> Can anyone explain to me what the story is with the restFP/saveFP
> symbols, which cause such inexplicable link problems with (some? all?)
> combinations of g77 and gcc code?  [I posted this query on
> macosx-dev@omnigroup.com a few days ago, but nobody wanted to bite].
> 
> For those as yet innocent of this, the problem is that in certain
> circumstances, links fail because the restFP and saveFP symbols are
> undefined.  Do a little bit of Googling, and you'll soon come across
> the advice to add -lcc_dynamic (or sometimes -lgcc, or even sometimes
> libgcc.a) to the link options.

One thing you should make absolutely sure is that you don't have a stray 
libgcc.dylib in your linker search path, in /usr/local/lib or in your 
case somewhere in /opt/local/lib. Due to one of Apple's linker 
"features", dynamic libs take precedence over static libs, so the 
presence of libgcc.dylib will shadow gcc's libgcc.a that should be 
included all the time.

The -lcc_dynamic flag will pull in libgcc.a via a symlink, because 
nobody is likely to have a libcc_dynamic.dylib, whereas chances for a 
the existence of a spurious libgcc.dylib are bigger. Depending on how 
you compiled your g77, it will have produced one (does opendarwin do 
this? Fink doesn't, it compiles g77 with the --disable-shared configure 
option), or some other program will install it, because it has been 
compiled with a version of gcc that had one.

If your linker links to both libgcc.a (via -lcc_dynamic) and 
libgcc.dylib (via -lgcc), results are unpredictable, pretty much what 
you are observing.

-- 
Martin




