[ROOT] pb making shared library

From: Nicolas de Sereville (deserevi@csnsm.in2p3.fr)
Date: Fri Apr 18 2003 - 13:59:54 MEST






  


hi rooters,

I'm tring to make a shared library of a class I wrote (see attachments). I make the 4 following steps without any problems :
    rootcint -f TAstroNucDict.cxx -c TAstroNuc.h TAstroNuc_LinkDef.h
    g++ -fPIC -I/$ROOTSYS/include -o TAstroNucDict.o TAstroNucDict.cxx - c
    g++ -fPIC -I/$ROOTSYS/include -o TAstroNuc.o TAstroNuc.cxx -c
    g++ -o libTAstroNuc.so -shared TAstroNuc.o TAstroNucDict.o

When I load the shared library in ROOT (3.05.03 CVS 14/04 on RH7.2), I obtain the following error :
root [0] .L libTAstroNuc.so
dlopen error: /home/astronuc/deserevi/root/macro/libTAstroNuc.so: undefined symbol: ShowMembers__9TAstroNucR16TMemberInspectorPc
Load Error: Failed to load Dynamic link library /home/astronuc/deserevi/root/macro/libTAstroNuc.so
*** Interpreter error recovered ***


I also tried to build the shared library using ACLIC doing ".L TAstroNuc.cxx++" but I obtain the following error, which is not the same that previously :
root [0] .L TAstroNuc.cxx++
Info in <TUnixSystem::ACLiC>: creating shared library /home/astronuc/deserevi/root/macro/TAstroNuc_cxx.so
dlopen error: /home/astronuc/deserevi/root/macro/TAstroNuc_cxx.so: undefined symbol: __tf6TNoyau
Load Error: Failed to load Dynamic link library /home/astronuc/deserevi/root/macro/TAstroNuc_cxx.so
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function `_start':
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference to `main'
/home/astronuc/deserevi/root/macro/file505QEz.o: In function `TAstroNuc::TAstroNuc(void)':
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x4e): undefined reference to `TNoyau::TNoyau(void)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x99): undefined reference to `TNoyau::TNoyau(void)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0xe4): undefined reference to `TNoyau::TNoyau(void)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x12f): undefined reference to `TNoyau::TNoyau(void)'
/home/astronuc/deserevi/root/macro/file505QEz.o: In function `TAstroNuc::TAstroNuc(char *, char *, char *, char *)':
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x305): undefined reference to `TNoyau::TNoyau(char *)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x353): undefined reference to `TNoyau::TNoyau(char *)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x3a1): undefined reference to `TNoyau::TNoyau(char *)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x3ef): undefined reference to `TNoyau::TNoyau(char *)'
/home/astronuc/deserevi/root/macro/file505QEz.o: In function `TAstroNuc::TAstroNuc(int, int, int, int, int, int, int, int)':
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x5c8): undefined reference to `TNoyau::TNoyau(int, int)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x619): undefined reference to `TNoyau::TNoyau(int, int)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x66a): undefined reference to `TNoyau::TNoyau(int, int)'
/home/astronuc/deserevi/root/macro/file505QEz.o(.text+0x6bb): undefined reference to `TNoyau::TNoyau(int, int)'
/home/astronuc/deserevi/root/macro/file505QEz.o: In function `TBuffer & operator>><TNoyau>(TBuffer &, TNoyau *&)':
/home/astronuc/deserevi/root/macro/file505QEz.o(.gnu.linkonce.t.__rs__H1Z6TNoyau_R7TBufferRPX01_R7TBuffer+0x1a): undefined reference to `TNoyau type_info function'
/home/astronuc/deserevi/root/macro/file505QEz.o: In function `TBuffer & operator>><TResonnance>(TBuffer &, TResonnance *&)':
/home/astronuc/deserevi/root/macro/file505QEz.o(.gnu.linkonce.t.__rs__H1Z11TResonnance_R7TBufferRPX01_R7TBuffer+0x1a): undefined reference to `TResonnance type_info function'
collect2: ld returned 1 exit status
*** Interpreter error recovered ***


I'm not familiar at all with shared library (and C++ class neither), so any help is welcomed. One more question, building a shared library for a class A (TAstroNuc) which calls other classes B (TNoyau) and C (TResonnance), do I have to build additional shared libraries for A and B?

Thanks in advance.
Nicolas
-- 
:-------------------------------:
:     Nicolas de SEREVILLE      :
:         C.S.N.S.M.            :
:        Batiment 104           :
:     91405 ORSAY Campus        :
: Tel : (+ 33) (0)1 69 15 52 29 :
: Fax : (+ 33) (0)1 69 15 50 08 :
:-------------------------------:
#include <iostream.h> #include "TAstroNuc.h" //#include <gsl/gsl_sf_coulomb.h> ClassImp(TAstroNuc) TAstroNuc::TAstroNuc() { fNoy1 = new TNoyau(); fNoy2 = new TNoyau(); fNoy3 = new TNoyau(); fNoy4 = new TNoyau(); fTemp = 0; fReson = 0; fR0 = 0; fRc = 0; fRn = 0; } TAstroNuc::TAstroNuc(Char_t* name1, Char_t* name2, Char_t* name3, Char_t* name4) { fNoy1 = new TNoyau(name1); fNoy2 = new TNoyau(name2); fNoy3 = new TNoyau(name3); fNoy4 = new TNoyau(name4); fTemp = 0; fReson = 0; fR0 = 1.3; fRc = 0; fRn = 0; } TAstroNuc::TAstroNuc(Int_t Z1, Int_t A1, Int_t Z2, Int_t A2, Int_t Z3, Int_t A3, Int_t Z4, Int_t A4) { fNoy1 = new TNoyau(Z1, A1); fNoy2 = new TNoyau(Z2, A2); fNoy3 = new TNoyau(Z3, A3); fNoy4 = new TNoyau(Z4, A4); fTemp = 0; fReson = 0; fR0 = 1.3; fRc = 0; fRn = 0; } TAstroNuc::~TAstroNuc() { delete fNoy1; delete fNoy2; delete fNoy3; delete fNoy4; delete fReson; } // Masse reduite du systeme en u.m.a. Double_t TAstroNuc::Mu() const { return (Double_t)fNoy1->GetA() * fNoy2->GetA() / (fNoy1->GetA() + fNoy2->GetA()); } // Parametre de Sommerfield. E en MeV Double_t TAstroNuc::Eta(Double_t energie) const { if ( energie == 0 ) { cout << "Attention, Eta ne peut etre calcule avec une energie nulle" << endl; // exit(1); } // Rolfs ("Cauldrons in the Cosmos") p156 (4.15) Double_t eta = 1./137.036 * fNoy1->GetZ()*fNoy2->GetZ() * TMath::Sqrt(Mu()*931.5 / 2 / energie); return eta; } // rayon nucleaire Double_t TAstroNuc::Rn() const { Double_t res; if ( fNoy1->GetA() == fNoy2->GetA() ) { res = fR0 * (TMath::Power(fNoy1->GetA(), 1./3.) + TMath::Power(fNoy2->GetA(), 1./3.)); } else { res = fR0 * TMath::Power(TMath::Max(fNoy1->GetA(),fNoy2->GetA()), 1./3.); } return res; } Double_t TAstroNuc::Rho(Double_t energie) const { // nombre d'onde k Double_t k = TMath::Sqrt(2 * Mu()*931.5 * energie / TMath::Power(197.,2)); return k * Rn(); } // Barriere Coulomabienne en MeV Double_t TAstroNuc::CoulombBarrier(Option_t *option) const { Double_t R, Z1Z2; if ( option == "in" ) { R = fR0 * (TMath::Power(fNoy1->GetA(), 1./3.) + TMath::Power(fNoy2->GetA(), 1./3.)); Z1Z2 = fNoy1->GetZ() * fNoy2->GetZ(); } else { R = fR0 * (TMath::Power(fNoy3->GetA(), 1./3.) + TMath::Power(fNoy4->GetA(), 1./3.)); Z1Z2 = fNoy3->GetZ() * fNoy4->GetZ(); } return 197./137.036 * Z1Z2 / R; } Double_t TAstroNuc::GamowPeak() const { return 0; } //section efficace en mb a l'energie 'energie' Double_t TAstroNuc::SigmaBW(Double_t energie) const { // facteur statistique Double_t w = (2*fReson->GetSpin() +1) / (2*fNoy1->GetSpin()+1) / (2*fNoy2->GetSpin()+1); Double_t g = fReson->GetGamma1() * fReson->GetGamma2() / fReson->GetGammaTot(); // calcul de lambda bar Double_t lbar = 197. / TMath::Sqrt(2 * Mu()*931.5 * energie); // definition de la BW selon ROOT Double_t bw = 2*TMath::Pi() * TMath::BreitWigner(energie, fReson->GetEnergie(), fReson->GetGammaTot()); // *10 : fm2 -> mb return TMath::Pi() * TMath::Power(lbar,2) * w*g * bw * 10; } // section efficace au maximum de la resonnance en mb Double_t TAstroNuc::SigmaMaxBW() const { // facteur statistique Double_t w = (2*fReson->GetSpin() +1) / (2*fNoy1->GetSpin()+1) / (2*fNoy2->GetSpin()+1); Double_t g = fReson->GetGamma1() * fReson->GetGamma2() / fReson->GetGammaTot(); // calcul de lambda bar Double_t lbar = 197. / TMath::Sqrt(2 * Mu()*931.5 * fReson->GetEnergie()); // *10 : fm2 -> mb return 4*TMath::Pi() * TMath::Power(lbar,2) * w*g/fReson->GetGammaTot() * 10; } // transforme la section efficace (mb) a l'energie E (MeV) en facteur // astrophysique (MeV.mb = keV.b) Double_t TAstroNuc::SigmaToSfactor(Double_t sigma, Double_t energie) const { return TMath::Exp(2*TMath::Pi()*Eta(energie)) * energie * sigma; } // calcule le facteur astrophysique a l'energie E (MeV) pour la resonnance // fReson Double_t TAstroNuc::SfactorBW(Double_t energie) const { return TMath::Exp(2*TMath::Pi()*Eta(energie)) * energie * SigmaBW(energie); } // Calcul de la penetrabilite de la barriere coulombienne avec E en MeV /*Double_t TAstroNuc::Penetrabilite(Double_t energie) const { // on calcule les fonctions de coulomb Int_t kmax = fReson->GetL(); const Int_t dim = kmax + 1; Double_t Fl[dim], Gl[dim], expo1, expo2; int status = gsl_sf_coulomb_wave_FG_array(0, kmax, Eta(energie), Rho(energie), Fl, Gl, &expo1, &expo2); if (status) cout << "erreur numero " << status << endl; // on calcule les penetrabilites // Pl = rho / (F**2 + G**2) cf P. Descouvemont Aussois 2000 return Rho(energie) / (TMath::Power(Fl[kmax],2) + TMath::Power(Gl[kmax],2)); }*/ void TAstroNuc::Print() const { cout << "Reaction : " << fNoy1->GetNom() << " + " << fNoy2->GetNom() << " ---> " << fNoy3->GetNom() << " + " << fNoy4->GetNom() << endl; } #ifndef __AstroNuc__ #define __AstroNuc__ #include "TObject.h" #ifndef __Noyau__ #include "TNoyau.h" #endif #ifndef __Resonnance__ #include "TResonnance.h" #endif class TNoyau; class TResonnance; class TAstroNuc : public TObject { private: TNoyau *fNoy1; // Noyau 1 TNoyau *fNoy2; // Noyau 2 TNoyau *fNoy3; // Noyau 3 TNoyau *fNoy4; // Noyau 4 TResonnance *fReson; // Parametre d'une resonnance Double_t fTemp; // Temperature du milieu (T6) Double_t fR0; // Rayon en fm Double_t fRc; // "Classical turning point" en fm Double_t fRn; // Rayon nucleaire en fm public: TAstroNuc(); TAstroNuc(Int_t Z1, Int_t A1, Int_t Z2, Int_t A2, Int_t Z3, Int_t A3, Int_t Z4, Int_t A4); TAstroNuc(Char_t* name1, Char_t* name2, Char_t* name3, Char_t* name4); ~TAstroNuc(); TNoyau* GetNoy1() const { return fNoy1; }; TNoyau* GetNoy2() const { return fNoy2; }; TNoyau* GetNoy3() const { return fNoy3; }; TNoyau* GetNoy4() const { return fNoy4; }; Double_t GetTemperature() const { return fTemp; }; TResonnance* GetResonnance() const { return fReson; }; Double_t GetR0() const { return fR0; }; Double_t GetRc() const { return fRc; }; Double_t GetRn() const { return fRn; }; void SetTemperature(Double_t temp) { fTemp = temp; } void SetResonnance(TResonnance* reso) { fReson = reso; } void SetR0(Double_t r0) { fR0 = r0; }; void SetRc(Double_t rc) { fRc = rc; }; void SetRn(Double_t rn) { fRn = rn; }; Double_t QValue() const { return fNoy1->GetExcesMasse() + fNoy2->GetExcesMasse() - fNoy3->GetExcesMasse() - fNoy4->GetExcesMasse();}; Double_t CoulombBarrier(Option_t *option) const; Double_t GamowPeak() const; Double_t Rn() const; Double_t Mu() const; Double_t Eta(Double_t energie) const; Double_t Rho(Double_t energie) const; // Double_t Penetrabilite(Double_t energie) const; Double_t SigmaBW(Double_t energie) const; Double_t SigmaMaxBW() const; Double_t SfactorBW(Double_t energie) const; Double_t SigmaToSfactor(Double_t sigma, Double_t energie) const; void Print() const; ClassDef(TAstroNuc,1) // Une Classe d'AstroNuc }; #endif #ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class TNoyau; #endif



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET