ok, so you have different way to go:
- 1st solution:
Use the LAPACK build under Visual Studio or nmake to build LAPACK library and link your program with it in Mingw. This will need to add some Intel Fortran Compiler library at linking
The package is available at
http://icl.cs.utk.edu/lapack-for-windows/
Here is how to call Fortran from C++
The extern "C" directive
First of all, the extern "C" linkage specification must be used to declare any modules that are not written in C++.
So you will have to define the Fortran routine in your C++code:
- Code: Select all
extern "C" void dgeqrf_ (const int &m, const int &n, double da[], const int &lda, double dtau[], double dwork[], const int &ldwork, int &info)
Case sensitivity
C++ is a case sensitive language, Fortran is not. The name of the Fortran routine is mangled by the compiler. All references to Fortran symbols may be specified in lowercase or in uppercase (depends on the compiler) in C++ calls.
The underscore (_)
In many Fortran compilers, an underscore (_) is appended by default at the end of definitions and references to externally visible symbols (subroutines, functions, etc.). This happens for Solaris and Digital UNIX f77 compilers, for g77 compiler and for hepf77 compiler interface; on HP-UX the +ppu option must be added to the f77 compiler to activate this feature; on AIX -qextname must be added to the xlf compiler. The appended underscore is a standard for HEP Fortran libraries (e.g. CERNLIB). In a C++ call the Fortran subroutines or functions must be specified with an appended underscore.
Passing parameters
An important thing to remember is that C++ passes all parameters by value (except arrays and structures). Fortran passes them by reference. It is therefore necessary to specify in the C++ function prototypes that the Fortran subroutines and functions expect call-by-reference arguments using the address-of (&) operator.
Arrays
C++ stores arrays in row-major order, whereas Fortran stores arrays in column-major order. The lower bound for C++ is 0, for Fortran is 1. This mean that the Fortran array element myarray(1,1) corresponds to the C++ array element myarray[0][0]; whereas myarray(6,8) corresponds to myarray[7][5];
[color=darkred]
- 2nd Solution:
use the CLAPACK build (LAPACK tranlated to C) under Visual Studio to build LAPACK library and link your program with it in Mingw.
The package is available at
http://icl.cs.utk.edu/lapack-for-windows/
Hope it helps
Julie