Link to home
Start Free TrialLog in
Avatar of Ravi Kiran Reddy Katkuri
Ravi Kiran Reddy KatkuriFlag for Australia

asked on

FORTRAN linking error

Hi,

I am porting the application with old fortran compiler and old visual studio(VC5) to new fortran compiler 11 and visual studio  2005. Application contains both 'C' and fortran code. I am compiling the fortran code and creating library called server_lib.lib(library is createing with some warnings) and linking to the 'C' code. while linking application is giving some below linking errors.

2>Linking...
2>server_lib.lib(Preparx.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Query.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Utm.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Runvhf.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(PFLTPV.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Qdesic.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Headach.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Plotky.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Terrain.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Morpho.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Diflos.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Micro.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(OpenGL_F.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Violet.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Fieldp.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(Step.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>server_lib.lib(White.obj) : error LNK2005: _SERVERSTUFF already defined in server_lib.lib(Athena7.obj)
2>.\Debug/Server.exe : fatal error LNK1169: one or more multiply defined symbols found


above "serverstuff" is defined in server.for file and this server.for is included in all above files. Please find the below code block from server.for file.

INTEGER iErrPipe !error code for pipe i/o
INTEGER clientIndex !index into client list
CHARACTER*136 Buffer(17) !buffer for pipe i/o
CHARACTER dBuffer(2313) !buffer for pipe i/o
EQUIVALENCE(dBuffer,Buffer)
COMMON/serverstuff/clientIndex,dBuffer

DATA dBuffer(2313)/0/


Why the above code is giving redecleration error? How it worked with previous fortran compiler? When I am commenting the "COMMON/serverstuff/clientIndex,dBuffer" line then it's linking perfectly, but the application is crashed..

Please give me any idea as I don't know about fortran language
Avatar of dcesari
dcesari
Flag of Italy image

Hi, the point is that your included bit of code contains both a declaration of a common block, i.e.

COMMON/serverstuff/clientIndex,dBuffer

and its initial definition as

DATA dBuffer(2313)/0/

Actually the initial definition can take place only in a single point of the code, so you should include only the declaration of the COMMON in all your files and the definition with DATA statement should appear only in one of them. Probably the old compiler did not respect strictly the standard and forgave this error, correcting it automatically in some way.
ASKER CERTIFIED SOLUTION
Avatar of dcesari
dcesari
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial