- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Forum Members:
I'm trying to resurrect an ancient FORTRAN IV program from the 1960s. I'm having trouble with the Linker telling me that a symbol is multiply defined. I get these messages, where CSTAR is a Common block, PERDAT is another BLOCK DATA file
Severity Code Description Project File Line Suppression State
Error fatal error LNK1169: one or more multiply defined symbols found (in TND4729)
Error error LNK2005: _CSTAR already defined in TND4729.obj (in Perdat.obj)
Can anyone help me to sort out this mess.
My first question to help me understand what is going on is: Where does the block data get inserted in the program?
Regards,
Gordon B
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This happens when a COMMON contains initializations in more than one program unit. All such initializations should be in a BLOCK DATA subprogram only. Look in TND4729 and move any initialization of variables in common CSTAR to the BLOCK DATA subprogram.
A common technique for ensuring that a BLOCK DATA subprogram is included is to name it in an EXTERNAL statement in the main program. Otherwise it's just another program unit that is compiled and linked into the application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With BLOCKDATA placed in a separate source file by itself, you run the risk of leaving out the corresponding .OBJ file at link time. If this happens, the common blocks may be used in other subprograms without their contents having been initialized, and there may be no compiler or linker error messages to warn you of that. Steve's comment shows you how to keep that from happening.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page