- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or in Visual Studio, right click on the name of the source file in the "Solution Explorer" pane and select Compile.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page