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

problem with compile gofr.f fortran code

hamid_mosaddeghi
Beginner
447 Views
Hi

I have ifort 11 , after compile this code ,I get error

[hamid@localhost untitled folder]$ ifort gofr.f
/opt/intel/Compiler/11.1/064/lib/ia32/for_main.o: In function `main':
/export/users/nbtester/x86linux_nightly/branch-11_1/20091202_010000/libdev/frtl/src/libfor/for_main.c:(.text+0x4d): undefined reference to `MAIN__'
/tmp/ifortqxUaHf.o: In function `gofr_':
gofr.f:(.text+0x93a): undefined reference to `uread_'
gofr.f:(.text+0x94e): undefined reference to `dcell_'
gofr.f:(.text+0xace): undefined reference to `invert_'

---------------------------------------------------

I change command to :

[hamid@localhost untitled folder]$ ifort gofr.f uread.f dcell.f invert.f
/opt/intel/Compiler/11.1/064/lib/ia32/for_main.o: In function `main':
/export/users/nbtester/x86linux_nightly/branch-11_1/20091202_010000/libdev/frtl/src/libfor/for_main.c:(.text+0x4d): undefined reference to `MAIN__'

--------------------------------------------

please help me. I attached gofr.f and other file

Best Regards

0 Kudos
3 Replies
mecej4
Honored Contributor III
447 Views
There should be one and only one main program used to build an executable. Likewise, any needed routines such as hread() should be satisfied by the existence of one and only one object file containing a corresponding external symbol. Such object files may be compiled from your sources or may be present in a library that is searched either because you ask for that explicitly or the compiler knows to search implicitly.

The compiler is telling you that none of the four source files that you compiled and linked contains a main program. If you examine your source files, you will find that you have multiple definitions of hread(). You will have to remove at least these two errors before you can build an executable.

You need to acquaint yourself with the basic framework of the process for building object files and executable programs from source files, by reading textbooks and Fortran compiler manuals.
0 Kudos
hamid_mosaddeghi
Beginner
447 Views
Hi

I need to compile only gofr.f but I have problem with this code.

I use this command for compile and link codes;

[hamid@localhost untitled folder]$ ifort -O3 gofr.f uread.f dcell.f invert.f
/opt/intel/Compiler/11.1/064/lib/ia32/for_main.o: In function `main':
/export/users/nbtester/x86linux_nightly/branch-11_1/20091202_010000/libdev/frtl/src/libfor/for_main.c:(.text+0x4d): undefined reference to `MAIN__'

or


[hamid@localhost untitled folder]$ gfortran -O3 -ffast-math gofr.f uread.f dcell.f invert.f
/usr/lib/gcc/i686-redhat-linux/4.4.4/libgfortranbegin.a(fmain.o): In function `main':
(.text+0x28): undefined reference to `MAIN__'
collect2: ld returned 1 exit status




please help me. i don't know how I solve problem
0 Kudos
Steven_L_Intel1
Employee
447 Views
Please read mecej4's response above.
0 Kudos
Reply