Linking error (LNK2005) VS2008

Hi all,

I’m getting the linker error LNK2005 in VS2008 (PVF) “main already defined in f90main.obj” in my codes. Main.f95 file is module where just the definitions/declarations for subruotines are, each subroutine implementation resides in seprate file.

MODULE main

INTERFACE
!
SUBROUTINE first(a,d,e)
 IMPLICIT NONE
...................
END SUBROUTINE FIRST

END INTERFACE

END MODULE MAIN

and referencing the module in main program :

Program  MyProgram 
use main
implicit none 
.........
End program MyProgram

Any idea?

It can’t be a major mistake, possibly I’m missing something obvious with setting some linker, compiler configurations, switches etc.


Any help/suggestions will be appreciated,

Any idea please? What could be wrong, played almost with all the configs in VS but th result is same. Googling around doesn’t return any results other than mine posts.

Hi Ronan,

You can use “main” as a module or subroutine name since it’s reserved for the “main” routine which the compiler needs to insert in order to interface with the OS. Changing “main” to something else will work around the issue.

Hope this helps,
Mat