Hi all,
I managed to write a wrapper class, that executes a Fortran function, somehow it works but obvious I didn’t it completely right, as there are still some issues one of them is that cint crashes when loading the .so file twice (reloading it).
I placed a reduced version with working makefile in a tar archive in the attachment. Maybe someone can give me some hints what I made wrong while creating the .so - file,
Thanks,
J.
The makefile executes the following
f77 -Wall -D_REENTRANT -fPIC -I/products/ROOT/3.10_03/gcc-2.95.3/root/include -c -o fort.o fort.F
g++ -Wall -D_REENTRANT -fPIC -I/products/ROOT/3.10_03/gcc-2.95.3/root/include -c -o TFtest.o TFtest.C
echo "Generating dictionary TFtestDict.cxx..."
rootcint -f TFtestDict.cxx -c TFtest.h TFtestLinkDef.h
g++ -Wall -D_REENTRANT -fPIC -I/products/ROOT/3.10_03/gcc-2.95.3/root/include -c -o TFtestDict.o TFtestDict.cxx
g++ -shared -Wl,-soname,TFtest.so -O fort.o TFtest.o TFtestDict.o -lg2c -o TFtest.so
The Forran file just summs up 2 numbers
SUBROUTINE SUMME(Ia,Ib,Ic)
Ic=Ia+Ib
RETURN
END
The C-header file declares an class inherited from the TObject Class, and the external Fortran code
#ifndef __TFtest__
#define __TFtest__
#include "TObject.h"
extern "C" void summe_ (int &a, int &b, int &c);
class TFtest:public TObject
{
public:
void DoIt(void);
Int_t fA;
Int_t fB;
Int_t fC;
private:
Int_t fD;
ClassDef(TFtest,1) // Wrapper Class to Fortran
};
The implementation of the class just calls the Fortran subroutine
#include "TFtest.h"
ClassImp(TFtest)
void TFtest::DoIt(void)
{
summe_(fA,fB,fC);
}
Ftest.tar.gz (1.03 KB)