Re: quick question about linking Fortran and C



On 17 aug, 15:48, otto.piv...@xxxxxxxxx wrote:
Hello,

The gist of my problem is that when I compile testc.c

int
MAIN__( int argc, char* argv[] )
{printf("argc is %i", argc);
return(0);}

with icc -c testc.c

and link with
ifort -o test testc.o
I get garbage for argc and a bad address for argv. This works fine
with gfortran, but g77 and ifort both give problems.

Any advice is appreciated; many thanks in advance.

The problem is that ifort assumes that the main program is a
Fortran program. That is clearly not the case here. Use the
option -no-for_main (or something similar) for the compile and
link step.

As for icc/g77, I think you need to tell icc to produce
object files suitable for use with gcc. I do not know the
option.

Regards,

Arjen

.



Relevant Pages