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

multiply defined symbol.

pirveli
Beginner
529 Views
Hi there!

When linking I get an error
:
ld: fatal: symbol `realnumofbins_' is multiply defined:
(file align.o and file waddTempl.o);
about 20 times with diferent second .o file.
Could someone tell me what to do with this? This program is not mine I just have to compile it. It was originally written for HP OS and I want to compile it on SunOS. I read f77 manual but didn't find (surely missed one) any flag I could use to let linker ignore this problem (if it is possible).

This is source code of first file eff.con included in align.f where realnumofbins is used (sorry for flooding):

===================
integer argmax, nbins, nbinsMax, iokey, ioscreen, ionull

parameter (argmax=30)


parameter (nbinsMax=2048)
data nbins/1024/

common /realNumOfBins/nbins

parameter (iokey=5)
parameter (ioscreen=6)
parameter (ionull=88) ! hopefully not used otherwise...

integer numOfArg
character arglist*60
logical yes, no

dimension arglist(argmax)

data yes/.true./
data no/.false./
=============================

Looking forward to hear form anyone...
0 Kudos
3 Replies
TimP
Honored Contributor III
529 Views
This surely is not the place to get advice on the SunOS linker. As you found, the behavior when you link multiple copies of the same named subroutine is platform dependent, and the only portable answer is don't do it. I don't think you give enough information to know whether the HP linker used by the original programmer kept the first or last copy seen at link time.
0 Kudos
Hirchert__Kurt_W
New Contributor II
529 Views
I assume that eff.con is alsoINCLUDEd into waddTempl.f and the other 20 routines reported in the error messages. The problem is the statement
data nbins/1024/
By the Fortran standard, this statement should be in a BLOCK DATA program unit, not in a FUNCTION or SUBROUTINE, because it is initializing a variable in a named COMMON block (i.e., nbins is in /realNumOfBins/). Many implementations allow the extension of putting such a DATA statement in an ordinary procedure, but nearly all will complain if you provide more than one initialization for a COMMON block (even if all the initializations specify the same value(s)).
I suggest removing the above statement from eff.con and either adding it to _one_ of the routines currently including eff.con or, better yet, putting it in a BLOCK DATA program unit.
0 Kudos
pirveli
Beginner
529 Views
Thanks for help but I actually did it by using "-z muldefs" when linking. But thanks anyway :)
0 Kudos
Reply