This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
calling c++ from fortran
- From: "Dima Sorkin" <dima dot sorkin at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 9 Jul 2007 22:17:01 +0300
- Subject: calling c++ from fortran
Hi.
I have a library written on Fortran 90, it does some calculations
with the user provided function
INTEGER, PARAMETER :: DP = SELECTED_REAL_KIND(15,70)
SUBROUTINE FDF(Z,F,DF)
COMPLEX(KIND=DP), INTENT(IN) :: Z
COMPLEX(KIND=DP), INTENT(OUT) :: F, DF
...
I want to wrap a call to a c++ function
// 'fcc.hpp'
extern "C"
void fcc(complex<double> z, complex<double> &f, complex<double> &df);
inside 'SUBROUTINE FDF'.
How do I do it, and how do I then link the fortran module with
the c++'s object file 'fcc.o' ?
-- All compilations are done by GCC (or the 4.1.2 g++ and gfortran pair is used,
or the 3.4 g++ and g77 )
-- c++ runtime is properly initialized, as the program starts in c++, then calls
fortran which then wants to call c++.
Thank you.
Dima.