- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Expert Users,
I'm a Mac user with OS X EI Capitan 10.11.6. I am trying to compile four fortran codes (distr.f90, global.f90, toolbox.f90, main.f90) with intel fortran compiler 2017 by the following command:
ifort -c distr.f90
ifort -c global.f90
ifort -c toolbox.f90
ifort -c main.f90
ifort main.f90 global.f90 toolbox.f90 distr.f90 -o test.exe
However, I got the following error after the last command:
duplicate symbol _global._ in:
/var/folders/4m/j48kkdrj63zcx3zxhxp6rf100000gn/T/iforto9DdFb.o
/var/folders/4m/j48kkdrj63zcx3zxhxp6rf100000gn/T/ifort1RnV6O.o
ld: 1 duplicate symbol for architecture x86_64
Is there anything wrong with the process either the compiling codes or others?
I am in a hurry to finish a project. I appreciate your prompt help and support! Thank you very much in advance!
Best,
Fu
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One obvious error that you committed is that you compiled each source file twice, once separately, and again the last command, which causes all the source files to be recompiled. You would save some time by replacing ".f90" by ".o" in the last command.
Is "global" a data item or a code item (meaning, the name of a subroutine or function)? You would have found out which source files contain declarations of "global" if you had used ".o" instead of ".f90" in the last command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have more than one Fortran main program (f77 PROGRAM header or f66 implied header), that would cause a conflict in linking the multiple files. f66 implied main program has been known to happen due to corruption of source file causing compiler to see a compilation unit with no PROGRAM, SUBROUTINE, or FUNCTION header.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for suggestion of replacing ".f90" by ".o". Global is a module (code item). I realized that I mistakenly added "include "global.f90"" at the beginning of the main.f90 file, which caused me the error. After deleting it, it works perfectly.
mecej4 wrote:
One obvious error that you committed is that you compiled each source file twice, once separately, and again the last command, which causes all the source files to be recompiled. You would save some time by replacing ".f90" by ".o" in the last command.
Is "global" a data item or a code item (meaning, the name of a subroutine or function)? You would have found out which source files contain declarations of "global" if you had used ".o" instead of ".f90" in the last command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for pointing out what the issue might be. I mistakenly added "include "global.f90"" at the beginning of the main.f90 file. After deleting it, I successfully complied all the main program file.
Tim P. wrote:
If you have more than one Fortran main program (f77 PROGRAM header or f66 implied header), that would cause a conflict in linking the multiple files. f66 implied main program has been known to happen due to corruption of source file causing compiler to see a compilation unit with no PROGRAM, SUBROUTINE, or FUNCTION header.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page