Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Fortran Generic Procedures

Anshuman_Singh
Beginner
483 Views
I am trying to compile a simple module with generic procedures from the book "Fortran95/2003 for scientists and engineers" by Chapman. The compilation produces libifcoremt.lib(for_main.obj) : error LNK2019: unresolved external symbol _MAIN__ referenced in function _main erorr.

The module is as follows:


Module GenericTestModule
IMPLICIT NONE
TYPE :: VEctor
real :: x
real:: y
contains
generic :: add =>addvect, addscaler
procedure, pass::addvect
procedure, pass::addscaler
end type vector
PRIVATE::addvect, addscaler
contains
type(vector) Function addvect(this, v2)
class(vector):: this
class(vector)::v2
addvect%x=this%x+v2%x
addvect%y=this%y+v2%y
end function addvect

type(vector) Function addscaler(this, v2)
class(vector):: this
real::v2
addscaler%x=this%x+v2
addscaler%y=this%y+v2
end function addscaler
end module GenericTestModule

If I add the following lines
Program test
End Program

The the compilation goes through with no erros. Is this a bug? I am using Intel Visual Fortran compiler 12.1 update 1 with visual studio 2010 on Windows XP.
Thanks.
Anshuman.
0 Kudos
2 Replies
Wendy_Doerner__Intel
Valued Contributor I
483 Views
The compiler was trying to build a main program and without the added lines you don't have a main program. If you want to compile to an object file (to be linked later with a main program) you can use the /c option.
0 Kudos
Steven_L_Intel1
Employee
483 Views
Or in Visual Studio, right click on the name of the source file in the "Solution Explorer" pane and select Compile.
0 Kudos
Reply