linking errors in C language from fortran library

Jugoslav Dujic
Total Points:
6,542
Status Points:
6,542
Black Belt
July 3, 2009 12:59 AM PDT
Rate
 
#1
Quoting - cvnravi
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)

above "serverstuff" is defined in server.for file only and this server.for is included in all above files like Athena7.for,White.fort,Step.for etc.

It sounds as if you did redeclaration by include, like:

File Preparx.for
==========================
INCLUDE "Serverstuff.for"
SUBROUTINE Preparx()
...
END
INCLUDE statement basically works as a copy/paste macro, and in effect you define Subroutine ServerStuff in every of your sources. I don't think that C/Fortran has anything to do with that error.

I don't know how it compiled with another compiler, but that's not the way to do things in Fortran. Actually, that's not how to do things in C either -- C include files should contain just function prototypes, not their bodies.

If my analysis is correct, you should get rid of those INCLUDE lines. Have in mind, though, that I haven't seen your actual code and that I might easily have misdiagnosed the situation.

--------
Jugoslav
www.xeffort.com


Intel Software Network Forums Statistics

8472 users have contributed to 31603 threads and 100652 posts to date.
In the past 24 hours, we have 31 new thread(s) 115 new posts(s), and 163 new user(s).

In the past 3 days, the most popular thread for everyone has been gemm(A,A,A) like possible? The most posts were made to gemm(A,A,A) like possible? The post with the most views is Dear Steve, excuse me for a d

Please welcome our newest member Edwin B. Ramayya