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

undefined reference to `MAIN__'

Alex_L_
Beginner
2,374 Views

Hi! My system: Debian 7.4 x86_64 / Intel Fortran Composer XE for Linux 2013 SP1 Update 2 / ifort version 14.0.2

After installation Intel Fortran Composer I used:  source /opt/intel/bin/compilervars.sh intel64

I'm trying to compile my *.f files with this command:

ifort -nofor-main -O2 -r8 -extend-source 80 -warn general *.f -o myprog

but this error occurs:

/opt/intel/composer_xe_2013_sp1.2.144/compiler/lib/intel64/libifcore.a(for_main.o): In function `main':
for_main.c:(.text+0x54): undefined reference to `MAIN__'

What's wrong here? Thanks in advance! Alex.

 

0 Kudos
4 Replies
Alex_L_
Beginner
2,374 Views

Without -nofor-main i have:

/opt/intel/composer_xe_2013_sp1.2.144/compiler/lib/intel64/for_main.o: In function `main':
/export/users/nbtester/efi2linux_nightly/branch-14_0/20140121_010000/libdev/frtl/src/libfor/for_main.c:(.text+0x42): undefined reference to `MAIN__'

0 Kudos
Lorri_M_Intel
Employee
2,374 Views

Since you are creating a final executable, you need to have a main program, one where the execution can start.

Either you need to have a Fortran program that is the main program, or a C program.

It does not seem like you have either in this case.

                  --Lorri

0 Kudos
TimP
Honored Contributor III
2,374 Views

Fortran main program is one beginning with PROGRAM (or, in f66 style, no procedure name declaration).  Without it, the linker doesn't have an entry point to start the program.

0 Kudos
John4
Valued Contributor I
2,374 Views

You're actually telling the compiler to compile AND link.  To compile only, do:

-fort -c *.f

That will generate some *.o files.  Then, if you have a main program unit on the Fortran side (i.e., one with PROGRAM... END PROGRAM), you can link with:

ifort -o myprog *.o

If your main program unit is on the C-side, then you'll need something like:

ifort -c *.f

icc -o myprog *.c *.o
 

0 Kudos
Reply