multiply defined symbol.

multiply defined symbol.

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...

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.

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.

Thanks for help but I actually did it by using "-z muldefs" when linking. But thanks anyway :)

Leave a Comment

Please sign in to add a comment. Not a member? Join today