Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Problem linking files

dschleic
Beginner
341 Views
Hello,

I currently try to link a C-program and a Fortran-subprogram with some libraries:

icc -c -Dr4 -Dp4 -DI686 testsuite.C
ifort -c solve_rate.f
ifort -g -L/opt/intel/fc/9.0/lib -lcprts -lcxaguard -lguide_stats -lifcoremt -limf -lirc_s -lsvml -lcxa -lguide -lifcore -lifcoremt_pic -lifport -lirc -lompstub -lunwind -o testsuite testsuite.o solve_rate.o

Precompiling works, however linking gives the following error messages:

/opt/intel/fc/9.0/lib/for_main.o(.text+0x39): In function `main':
: undefined reference to `MAIN__'

However, in testsuite.C, I have defined a function void MAIN__(). I also tried linking with ifort, but that gives the same error message. Does anybody have an idea what I can do?

Thank you in advance,

Dominik

0 Kudos
3 Replies
Dmitry_B_Intel
Employee
341 Views

Dominik,

It looks as if icc interprets testsuite.C file as C++ source. If you rename it to testsuite.c or alternatively add extern "C" linkage to MAIN__ that willsolve the problem.

Dima

0 Kudos
dschleic
Beginner
341 Views
Oh sorry, it is really a C++ program, that was a typo up there.
0 Kudos
Steven_L_Intel1
Employee
341 Views
Add -nofor_main to the ifort command doing the link. This tells ifort that the main program is not Fortran.
0 Kudos
Reply