gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1568 Posts in 518 Topics by 754 Members - Latest Member: irekzawadzki December 03, 2021, 07:39:31 AM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  Macintosh  |  error of duplicate symbol
gfx
gfxgfx
 

Author Topic: error of duplicate symbol  (Read 2054 times)

Yoshihiko Haramura

  • Newbie
  • *
  • Posts: 5
error of duplicate symbol
« on: September 19, 2017, 06:08:02 AM »
Since a few days ago, I cannot compile my fortran program because an error "duplicate symbol _Cproperties in: xxx and yyy (xxx and yyy are files names of object files)" arises.
I think this message means the same common block name (properties) is used in different main routine or subprograms (xxx and yyy). This is probably true because if I changed the common block name of one program, compilation become successful. But these common blocks are different ones, of course. So this isn't a way to fix the error. Does anyone has an idea to fix this error?

cag

  • Newbie
  • *
  • Posts: 16
Re: error of duplicate symbol
« Reply #1 on: September 19, 2017, 11:24:35 AM »
One cause of this error is initializing portions of a COMMON block with DATA statements  in two or more files. You can declare a COMMON block as often as you need to, but you can only assign initial values to members of a COMMON block in one file.

For example, these two files are fine and will compile and link without error:

file1.f:
   PROGRAM  MAIN
        INTEGER I,J
        COMMON /properties/I,J
        DATA /I/10
    END

file2.f:
   SUBROUTINE FOOBAR
       INTEGER I,J
      COMMON /properties/I,J
   END

However, these two files will produce a duplicate symbol error when linked  together:
  file1.f:
   PROGRAM  MAIN
        INTEGER I,J
        COMMON /properties/I,J
        DATA I/10/
    END

file2.f:
   SUBROUTINE FOOBAR
       INTEGER I,J
      COMMON /properties/I,J
      DATA J/20/
   END

$ af77 file1.f file2.f
duplicate symbol _Cproperties


Yoshihiko Haramura

  • Newbie
  • *
  • Posts: 5
Re: error of duplicate symbol
« Reply #2 on: September 19, 2017, 09:54:06 PM »
Hi cag
Your advice works fine. Program yyy is for variable initialization and some data statements have been existed. And I added variables initialized with data statement in main program xxx to common block "properties". This is the reason to prevent compilation.
Thank you!!

Absoft User Forum  |  Support  |  Macintosh  |  error of duplicate symbol
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!