Fortran Wrapper Class

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)

HI Joe,

can you try and link f2c in addition to g2c? Maybe this helps.
Cheers,
Oliver

Thank you for this idea, but as i found out in between the problem is more basic than i thought.
I based the creation of my shared object file on the example “Hello.cxx/Hello.h” in the “test” directory of my root installatoin, but the Hello.so cerated with the original makefile also makes CINT to crash, when loaded twice with the
.L Hello.so
command.
What i would like to have is an .so file that behaves like an .so file that’s created with the ACLIC mechanism (an doesn"t chrash, when reloaded).
Cheers,
J.

Note that there seems to be a problem with reloading libraries with gcc 2.95.2

Cheers,
Philippe.