I have a C++ module that I have build as a library (myLib.a) and use this module from another C++-program. So far, so good.
Now, I whant to use this module from a fortran code...
I tried to wirte a c++ wrapper that called the module and a fortran wrapper that called the c++ wrapper:
Cpp-wrapper (c_wrapper.cpp) is something like this:
1 2 3 4 5 6 7 8 9
|
#includes..
void wrapper_c_(float *ins, float *outs)
{
int aInt;
int bInt;
myClass* ptr = myClass::create(...);
}
|
The fortran-wrapper (wrapper_f.f):
1 2 3 4 5 6 7 8 9 10 11 12
|
program wrapper_f
real aNumber
real bNumber
real ins(10), outs(10)
ins(1) = 1
ins(2) = 3
...
call wrapper_c(ins, outs)
return end
|
I build the Cpp file with
gcc -c wrapper_c.cpp
the fortran file with
gfortran -c wrapper_f.f
And I try to link all toghether with:
gfortran -o testProg wrapper_f.o wrapper_c.o -Wl myLib.a
But this just results in hundred of lines with errors. (Seems like the lib-file is not linked and found..)
I also tried to use extern C instead of Cpp, but did not get it to work this way either..
Do anyone have a clue how I can do this??