On Wed, 26 Jan 2005, Norman Gray wrote:
> On 2005 Jan 26 , at 10.33, Peter W. Draper wrote:
>
> > that's interesting. Yesterday I switched GAIA over to using libtool for
> > the final linking stages (I wanted to do a static link for some
> > pre-release, libtool actually turned out to be the simplest way to do
> > this) and now I'm missing the symbols:
> >
> > _f__xargc
> > _f__xargv
>
> Ah, the fix that worked for me with DIPSO and CCDPACK was to use a
> Fortran main, instead of a C main calling the Fortran RTL (the Fortran
> main calls a routine which initialises the argv). Since GAIA's
> currently linked using C++, this might be trickier to arrange....
> However the g77 RTL does the initialisation through a call to a routine
> f_setarg(argc,argv), which might be a rather nasty --
> compiler-dependent -- fallback if there's no more principled way of
> arranging this.
Norman,
hmm, I thought this all sounded vaguely familiar and now I'm looking at
it, it is (sorry should have remembered earlier). GAIA used to define
these symbols many years ago, until NDF obtained its C interface. At that
time Rodney introduced a new function "ndfInit" which you are supposed to
call from your C/C++ main function to make sure that argc and argv are
available to Fortran/NDF. Indeed this function has the lines:
/* On Linux, we need to define these global variables which are
referenced by the Fortran system routine GETARG. GETARG is not
actually called if ndfInit has been used, but the linker resolves
the reference to these variables by pulling in a function called
``main'' from a standard library, which then conflicts with the
user's ``main''. */
#if defined( LINUX )
int f__xargc;
char **f__xargv;
#endif
I don't think these declarations are actually used at the moment as I
cannot see a LINUX macro defined anywhere, so this has probably been "just
working" under Linux for a while. The obvious thing to do here is change
LINUX to __GNUC__ and see what happens. Grepping through the source tree
reveals that GAIA is the only user of ndfInit, so the harm maybe limited.
Cheers,
Peter.
|