Folks (specifically Peter),
On 2005 Jan 26 , at 16.56, Peter W. Draper wrote:
>>> /* 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 took this back out when I decided it was neater for ccdwish.c and
>> the
>> corresponding dipso C main to be linked with the Fortran compiler, but
>> it sounds like it might actually be useful again for this situation,
>> where we need the C++ compiler to do the link. It's probably better
>> than conditionalising on __GNUC__, since this macro in starconf.m4.in
>> is a convenient locus for doing any other magic which turns out to be
>> required in this situation.
>>
>> Perhaps it would be better named
>> FC_INITIALISE_FORTRAN_RUNTIME(argc,argv) or something. That would
>> cover this case and any others that cropped up.
[...]
> that does sounds like a better/safer plan, so go ahead and make the
> changes if you want. In the meanwhile I've committed the change to
> ndfInit.c and rebuilt GAIA successfully on OS X
I've added STAR_INITIALISE_FORTRAN to starconf.m4.in, used it in GAIA,
and removed the ifdef __GNUC__ stuff from ndfinit.c. I've updated
SSN/78.
Peter: GAIA's gaia/tkAppInit.C and gaia/mktclapp/tkAppInit.C now both
have main functions (only the former had before), and both call a new
function initFortran in gaia/initFortran.c, which utilises the results
of the STAR_INITIALISE_FORTRAN macro. I've confirmed that it still
works OK on GAIA, and I'm rebuilding my Linux tree right now.
All: In general, if you're mixing Fortran and C, I feel it's better to
use AC_FC_MAIN to define a pseudo-main in the C module, and link the
program using the Fortran compiler. In GAIA's case, this won't work
because the Fortran compiler can't link C++, so we have to go this
rather more indirect route, on top of finding the Fortran libraries and
linking them in, too.
Have a good weekend.
Norman
--
----------------------------------------------------------------------
Norman Gray : Physics & Astronomy, Glasgow University, UK
http://www.astro.gla.ac.uk/users/norman/ : www.starlink.ac.uk
|