[Fwd: Re: problem with shared libraries]

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Feb 10 1998 - 10:23:05 MET



attached mail follows:


Alexander Zvyagin wrote: > > IHEP, Protvino, Russia, 5-FEB-1998 > > Dear all, > > I have next files: F1.h F1.c F2.h F2.c LinkDef.h > ----------------------------------------- > // F1.h > #ifndef F1__include > #define F1__include > #include "TObject.h" > class F1 : public TObject > { > public: > F1(void) {} > ClassDef(F1,1) > }; > #endif // F1__include > ------------------------------------------ > // F1.c > #include "F1.h" > ClassImp(F1) > ------------------------------------------ > // F2.h > #ifndef F2__include > #define F2__include > #include "TObject.h" > class F2 : public TObject > { > public: > UInt_t a; > F2(void) {} > ClassDef(F2,1) > }; > #endif // F2__include > ------------------------------------------ > // F2.c > #include "F2.h" > ClassImp(F2) > ------------------------------------------ > // LinkDef.h > #ifdef __CINT__ > #pragma link off all globals; > #pragma link off all classes; > #pragma link off all functions; > #pragma link C++ class F1; > #pragma link C++ class F2; > #endif > ----------------------------------------- > Very simple files. > > Then i do: > ======================================================= > rootcint -f F1_Cint.cxx -c F1.h LinkDef.h > rootcint -f F2_Cint.cxx -c F2.h LinkDef.h > > g++ -O -fPIC -I /usr/local/root/include -c F1.c -o F1.o > g++ -O -fPIC -I /usr/local/root/include -c F2.c -o F2.o > > g++ -O -fPIC -I /usr/local/root/include -c F1_Cint.cxx -o F1_Cint.o > g++ -O -fPIC -I /usr/local/root/include -c F2_Cint.cxx -o F2_Cint.o > > g++ -O -shared F1.o F1_Cint.o -o ./F1.so > g++ -O -shared F2.o F2_Cint.o -o ./F2.so > > root > ******************************************* > * * > * W E L C O M E to R O O T * > * * > * Version 1.03/09 16 December 1997 * > * * > * You are welcome to visit our Web site * > * http://root.cern.ch * > * * > ******************************************* > > CINT/ROOT C/C++ Interpreter version 5.13.36, Nov 30 1997 > Type ? for help. Commands must be C++ statements. > Enclose multiple statements between { }. > root [0] .L F1.so > root [1] printf("%d\n",sizeof(F1)); > 12 > root [2] .L F2.so > root [3] printf("%d\n",sizeof(F2)); > 16 > root [4] printf("%d\n",sizeof(F1)); > 0 > ======================================================= > > Why after loading F2.so sizeof(F1)==0 ? > > OS: Linux 2.1.76 and 2.0.32 > > All files (+makefile) are in > http://gams.ihep.su/~zvyagin/home/ALICE/work/gen_SHAKER/test/ > > Thanks in advance, > Alexander. If you want to have 2 separate shared libraries and dictionaries, you should have two files LinkDef.h (say F1LinkDef.h and F2LinkDef.h). In your LinkDef.h, you reference two classes F1 and F2. In your first call to rootcint, you receive the error message: Warning: Link requested for undefined for undefined class F2 FILE: and for the second rootcint Warning: Link requested for undefined class F1 FILE: LINE:0 The best solution is to have one single dictionary for your two classes rootcint -f F1_Cint.cxx -c F1.h F2.h LinkDef.h Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:29 MET