Absoft User Forum

Support => Macintosh => Topic started by: Yoshihiko Haramura on September 19, 2017, 06:08:02 AM

Title: error of duplicate symbol
Post by: Yoshihiko Haramura 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?
Title: Re: error of duplicate symbol
Post by: cag 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

Title: Re: error of duplicate symbol
Post by: Yoshihiko Haramura 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!!