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

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

LIN2
Beginner
374 Views

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 Kudos
3 Replies
Arjen_Markus
Honored Contributor I
365 Views

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 Kudos
mecej4
Black Belt
355 Views

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 Kudos
Ron_Green
Moderator
341 Views

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 Kudos
Reply