- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your main program is C calling a Fortran library or routine, you'll need -nofor-main
and read the Developer Guide and Reference, Mixed Language programming, compiling and linking.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page