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

multiple definition of `main'

dupree
Employee
2,161 Views
I am trying to compile my code with intel fortran and C++ compiler. Part of the code is written in Fortran and thus compiled by ifort and the other part written in C and compiled by icc. Now here is the output of the linker:

/opt/intel_fce_80/bin/ifort -I/opt/intel/cmkl/8.1/include -I/home/pdu/libfdr/include -I/usr/local/topspin/mpi/mpich/include -I. -L/opt/intel/cmkl/8.1/lib/em64t -L/home/pdu/libfdr/lib -L/usr/local/topspin/mpi/mpich/lib64 -L/home/pdu/lib/scalapack-1.7.4 -L/home/pdu/lib/LAPACK -L/usr/local/topspin/lib -o test_lu.x test_lu.o pdlaprnt.o tpdgetf2.o tpdgetrf.o tpdlaswp.o util.o -lmkl_scalapack -lscalapack -lmkl_blacs -lmkl_lapack -lmkl_em64t -lmpich -lvapi -lmosal -lmtl_common -lmpga -lguide -lpthread
test_lu.o(.text+0x0): In function `main':
: multiple definition of `main'
/opt/intel_fce_80/lib/for_main.o(.text+0x0): first defined here
ld: Warning: size of symbol `main' changed from 70 in /opt/intel_fce_80/lib/for_main.o to 1808 in test_lu.o
ld: warning: i386 architecture of input file `test_lu.o' is incompatible with i386:x86-64 output
ld: warning: i386 architecture of input file `util.o' is incompatible with i386:x86-64 output
/opt/intel_fce_80/lib/for_main.o(.text+0x2e): In function `main':
: undefined reference to `MAIN__'

I have no idea why this is happening and I hope to use my main function in my C code. So, does anyone know how to get through this?


Thanks.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
2,161 Views
Add -nofor_main to the ifort line
0 Kudos
ctierney42
Beginner
2,161 Views
Also notice that test_lu.o and util.o are compiled at i386 and not x86-64. You wont be able to link until you fix that.


0 Kudos
Reply