Hi there,
I am not very used to programming and I am trying to call a Fortran function/subroutine with a C++ main program, but it haven't worked.
Untill now, I've been trying to build the easiest program possible, such as c++ calling a c = a + b fortran function. I am trying this on a VS 2005 c++ along with an Intel Visual Fortran.
I have been looking for some answers on this forum and I've made these routines:
c++--------
#include <stdio.h>
extern "C" {int fort(int*, int*);}
int main ()
{
int a, b, c;
a = 2;
b = 3;
c = fort(&a,&b);
return c;
}
---- end c++
fortran --------
INTEGER FUNCTION FORT (A,B)
!DEC$ ATTRIBUTES DLLEXPORT :: FORT
!DEC$ ATTRIBUTES ALIAS :'FORT' :: FORT
!DEC$ ATTRIBUTES REFERENCE :: A,B
IMPLICIT NONE
INTEGER, INTENT (IN) :: A,B
FORT = A + B
END FUNCTION FORT
----end fortran
They both compile without problems, but the linking step breaks on an LNK2019 error: unresolved external symbol _fort referenced in function _main.
I woud really appreciate if one could help.
Thanks a lot,
grspinto