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

swanmain.f:(.text+0x0): multiple definition of `MAIN__'; /mnt/c/FYP/adcirc_v55.01/work/odir44/driver

LIN2
初学者
1,126 次查看

I encounter the problem like this:

ld: /mnt/c/FYP/adcirc_v55.01/work/odir44/swanmain.o: in function `MAIN__':
swanmain.f:(.text+0x0): multiple definition of `MAIN__'; /mnt/c/FYP/adcirc_v55.01/work/odir44/driver.o:driver.F:(.text+0x0): first defined here
make[1]: *** [makefile:605: padcswan] Error 1
make[1]: Leaving directory '/mnt/c/FYP/adcirc_v55.01/work'
make: *** [makefile:517: padcswan] Error 2

what should i do

0 项奖励
3 回复数
Arjen_Markus
名誉分销商 II
1,117 次查看

A program can only have one MAIN program unit. In Fortran that is the program unit. Apparently your link statement includes two or more object files that are derived from a source file containing "program somename"'. You will have to check which one is the correct one. (Or perhaps one should be a subroutine)

0 项奖励
mecej4
名誉分销商 III
1,107 次查看

The error messages from the linker make it quite clear that both swanmain.o and driver.o contain main program units. Only one of the two should be used. Which one? That is for you to determine, based on what the files contain and what you are attempting to build.

0 项奖励
Ron_Green
主持人
1,093 次查看

If your main program is C calling a Fortran library or routine, you'll need -nofor-main 

HERE for details

 

and read the Developer Guide and Reference, Mixed Language programming, compiling and linking.

0 项奖励
回复