Hello,
I have a difficulty in Mixed language programming. There are many global variables in a fortran module, which have to be accessed from C++ main program. Although the compiler is giving no errors with the following simple structure, but, linker gives errors with - 'undefined reference to the common variable in C++ object'.
fortran module:
MODULE EXAMP
SAVE
REAL, X(4), Y(4), Z(4)
REAL, PARAMETER :: Pi =3.14159
END MODULE EXAMP
C++:
#include<iostream>
extern "C" float EXAMP_mp_X[4];
extern "C" float EXAMP_mp_Y[4];
extern "C" float EXAMP_mp_Z[4];
extern "C" float EXAMP_mp_Pi;
using namespace std;
int main()
{
.....
....
}
I am using Linux...g++ and gfortran compiler in the following way
gfortran -c mod.f
g++ -c testc.cpp
g++ -o test mod.o testc.o -llapack
Could anyone please share their experience in handling the similar problem. Thanking you,
But I'll post the framework I'm using as well. If you check out CLAPACK you will find lots of info on this.
There are also some issues with blaswrap.h depending on how you compile CLAPACK.