Software Archive
Read-only legacy content
Announcements
Important Update: Community Platform Migration​. Learn more​>
17060 Discussions

Multiply defined symbols ?!?

Intel_C_Intel
Employee
1,431 Views
I have 4 separate routines that have the same common block (called FRAME1) containing 5 integer variables.

Why would building result in the following message?

Linking...
v3scal.obj : error LNK2005: _FRAME1 already defined in v3grid.obj
Release/hdfviz.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

The common block "FRAME1" is identical in the 4 subroutines, so I don't see why the linker would have a problem with one of them.

I can get the program to link if I comment out the common block in v3scal.f, but then the program crashes with the following message when it tries to read an 11 MB HDF file.

forrtl: severe (157): Program Exception - access violation

I have run this program under Unix. Could the problems I'm having within Windows 2000 be related?
0 Kudos
6 Replies
Intel_C_Intel
Employee
1,431 Views
I reproduced this behavior on UNIX.

Is you situation like this?

  
          program  m   
          integer i(3)  
          common /abc/ i  
          data i /5,10,20/  
          print *, 'in main',i  
          call s   
          stop  
          end  
  
          subroutine s   
          integer i(3)  
          common /abc/ i  
          data i /5,10,20/  
          print *, 'in s',i  
          return  
          end  
  
f90 -c m.f  
f90 -c s.f  
f90 -o m m.o s.o  
ld:  
s.o: abc_: multiply defined  
f90: Severe: Failed while trying to link.  



The above will fail because fortran sets up two different commons on each object.

To get this to build you need to put them together so fortran treats them as one. In other words don't build two separate object modules containing commons then attempt to link them together.

f90 m.f s.f -o m
m
in main 5 10 20
in s 5 10 20
0 Kudos
Intel_C_Intel
Employee
1,431 Views
Sorry about the above. I appear to be a victim of some problem with cutting and pasting in windows. If I could delete and re-enter the above, I would.
0 Kudos
Steven_L_Intel1
Employee
1,431 Views
Pat, I fixed your entry. I did so by bracketing the code in
 and 
I also added a FONT SIZE="+1" tag to make it more readable.

I think you have it right - Arif has DATA-initialized a COMMON block in multiple routines, probably through an INCLUDE file.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,431 Views
> Sorry about the above. I appear to be a victim of
> some problem with cutting and pasting in windows.
> If I could delete and re-enter the above, I would.

Welcome to CVF forum, Pat :-). Neither you, nor Windows
are not doing anything wrong -- it's the forum software
that acts smart too much.
See this
thread for explanation on workarounding this.

(sorry, not related with the original post)

Jugoslav
0 Kudos
Intel_C_Intel
Employee
1,431 Views
Thank you folks! I got around my problem by commenting out my DATA statement and using regular assignments within an if-then block that checks whether the routine is being used for the first time. I didn't try simply merging the *.f files so that one big .obj file is created. I didn't have the problem on an HP Visualize workstation.
0 Kudos
Steven_L_Intel1
Employee
1,431 Views
You wouldn't have the problem on OpenVMS either - it all depends on how the linker deals with multiple definitions of an initialized COMMON.

Steve
0 Kudos
Reply