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

compiling errors...I don't know why it occurs about multiple definition between main.o and for_main.o

gtg330c
Beginner
1,408 Views

This is my problem below, if I have compiled my code by ifort, some errors has occurred. I don't know why for_main.o in /opt/intel/fce/9.0/lib/ make this kind of problems... However, main.f90 is made by me.

Could you let me know how to get a solution for my problem? Thanks.

[mycat@mycom dr]$ifort -O3 -tpp7 -Vaxlib -ip -o sm precision.o global.o global_param.o global_app.o main.o init.o
main.o(.text+0x0): In function `main':
: multiple definition of `main'
/opt/intel/fce/9.0/lib/for_main.o(.text+0x0): first defined here
ld: Warning: size of symbol `main' changed from 70 in /opt/intel/fce/9.0/lib/for_main.o to 4052 in main.o
ld: warning: i386 architecture of input file `precision.o' is incompatible with i386:x86-64 output
ld: warning: i386 architecture of input file `global.o' is incompatible with i386:x86-64 output
ld: warning: i386 architecture of input file `global_param.o' is incompatible with i386:x86-64 output
ld: warning: i386 architecture of input file `global_app.o' is incompatible with i386:x86-64 output
ld: warning: i386 architecture of input file `main.o' is incompatible with i386:x86-64 output
ld: warning: i386 architecture of input file `init.o' is incompatible with i386:x86-64 output
/opt/intel/fce/9.0/lib/for_main.o(.text+0x2e): In function `main':
: undefined reference to `MAIN__'
main.o(.text+0x17): In function `main':
: undefined reference to `f90_init'
main.o(.text+0x62): In function `main':
: undefined reference to `f_iof'
main.o(.text+0x82): In function `main':
: undefined reference to `f_iof'
main.o(.text+0xe2): In function `main':
: undefined reference to `f_iod'
main.o(.text+0xf8): In function `main':
: undefined reference to `f_iod'

............................ The same problems happens below this line....

0 Kudos
6 Replies
Ron_Green
Moderator
1,407 Views

Could you show me your main.f program? Do you have something like:

program main

...

end program main

If you

nm /opt/intel/fce/9.0/lib/for_main.o

You'll see that 'main' is defined in for_main.o ( "T main ). It is an entry point in the startup routines that wrap and launch your user PROGRAM.

so do this for me:

nm main.o

and look for symbol "main". Is it in main.o as a Target "T main"?

ron

0 Kudos
Ron_Green
Moderator
1,408 Views

forgot to add: I would bet $20 that somewhere in your code you have declared a variable named 'main'. Again, 'main' is a special name that you cannot use in your program.

rename 'main' in your code.

ron

0 Kudos
Steven_L_Intel1
Employee
1,408 Views
Another problem you have is that you used the IA-32 compiler to compile these sources but are then trying to use the x64 (EM64T/Intel 64) ifort to link them.
0 Kudos
gtg330c
Beginner
1,408 Views

Thanks for your helps.

As Steve mentions, this problemscan have solved by removing 'main.o' file because this object file of the previousversionmade that and, after then, I have recompiled my code to link.

Thanks.

0 Kudos
crkkos
Beginner
1,408 Views

I sourced the ifortvars.sh, iccvars.shto change to the 32 bit compiler for ifort and C respectivly, how do you do it for the linker?
0 Kudos
TimP
Honored Contributor III
1,408 Views
Quoting - crkkos

I sourced the ifortvars.sh, iccvars.shto change to the 32 bit compiler for ifort and C respectivly, how do you do it for the linker?
The 32-bit compilers automatically invoke the 32-bit linker, assuming the 32-bit g++ and binutils are installed. If you invoke ld directly, it is your responsibility to choose the 32-bit one.
You are using out of date versions of the compilers; an upgrade might be indicated, if only so that the advice seen on this forum may be more relevant.
0 Kudos
Reply