Hello Xiaorong, Are you familiar about making ROOT shared library? If not, my explanation was not kind enough. > noinst_HEADERS = \ > ParticleDict.h ParticleLinkDef.h \ > DimuonDict.h ParticleLinkDef.h Normally, you need to put those #pragma statements in LinkDef.h file and it must be after '#pragma link off all classes;'. Then, of course you have to regenerate and recompile the dictionaries. For more detail, please read ROOT documentation about compiling shared library. Thank you Masa Goto ----- Original Message ----- From: "Xiaorong Wang" <phyxxw@panther.gsu.edu> To: "'Masaharu Goto'" <MXJ02154@nifty.ne.jp>; "'Philippe Canal'" <pcanal@fnal.gov>; "'Cint'" <cint@pcroot.cern.ch>; <roottalk@pcroot.cern.ch> Sent: Saturday, April 19, 2003 9:27 PM Subject: RE: [CINT] FW: [ROOT] CINT and STL vector of private class > Dear Masa, > > Thanks for your reply. Sorry I still can not get it work. Could you tell > me where I should put those command. I tried following two way. > > 1) I add > #include <vector> > ...class > #ifdef __MAKECINT__ > #pragma link C++ class vector<Particle>; > #endif > in Particle class header file > > #include <vector> > ...class > #ifdef __MAKECINT__ > #pragma link C++ class vector<Dimuon>; > #endif > in Dimuon class header file > > when I run the root micro file I got > > ********************* > root [0] .L try.C > root [1] main() > Error: Can't call vector<Particle,__malloc_alloc_template<0> > >::push_back(*muon1) in current scope FILE:try.C LINE:29 > Possible candidates are... > filename line:size busy function type and name (in > vector<Particle,__malloc_alloc_template<0> >) > *** Interpreter error recovered *** > root [2] > ************************** > > 2) I wrote DimuonLinkDef.h and ParticleLinkDef.h files > > and in Makefile.am I added > > noinst_HEADERS = \ > ParticleDict.h ParticleLinkDef.h \ > DimuonDict.h ParticleLinkDef.h > > I got same error message like before. > > Thanks for your time! > > Xiaorong > > > > > -----Original Message----- > From: owner-roottalk@pcroot.cern.ch > [mailto:owner-roottalk@pcroot.cern.ch] On Behalf Of Masaharu Goto > Sent: Thursday, April 17, 2003 7:18 AM > To: Philippe Canal; Cint; roottalk@pcroot.cern.ch > Subject: Re: [CINT] FW: [ROOT] CINT and STL vector of private class > > Hello Xiaorong, > > I am happy to answer your question. > > This is a Cint limitation. You have STL container classes > vector<Dimuon> and vector<Particle> interpreted. they > work to some extent, but not perfect. You'll find this kind > of problem as you go on. Solution is to precompile > vector<Dimuon> and vector<Particle> in libDimuon.so > using #pragma link statement. > > > #include <vector> > > class Particle { .... }; > class Dimuon { .... }; > > #ifdef __MAKECINT__ > #pragma link C++ class vector<Dimuon>; > #pragma link C++ class vector<Particle>; > #endif > > Then, things will be fine. > > Thank you > Masa Goto > > > > > ----- Original Message ----- > From: "Philippe Canal" <pcanal@fnal.gov> > To: "Cint" <cint@pcroot.cern.ch> > Sent: Thursday, April 17, 2003 12:06 AM > Subject: [CINT] FW: [ROOT] CINT and STL vector of private class > > > > > > > > -----Original Message----- > > From: owner-roottalk@pcroot.cern.ch > > [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Xiaorong Wang > > Sent: Tuesday, April 15, 2003 11:21 PM > > To: 'Rene Brun' > > Cc: 'Root Mailinglist' > > Subject: [ROOT] CINT and STL vector of private class > > > > > > Dear Root expert, > > > > I need your help on this issue. I am using ROOT 3.01/05, linux 7.3. > > Thanks for your time. > > > > I created two private class Paricle and Dimuon(two particles build one > > Dimuon), and use > > > > rootcint -f $*Dict.C -c $(CINTFLAGS) $(DEFS) $(INCLUDES) $*.hh > > > > to generate the root dictionary and library file libDimuon.so. > > > > I load this library and use STL vector in root macro file > > > > ********************* > > #include <iostream> > > #include <fstream> > > #include <stdio.h> > > #include <vector> > > > > class Dimuon; > > class Particle; > > > > void main() > > { > > gSystem->Load("install/lib/libDimuon.so"); > > vector<Dimuon> DimuVec; > > vector<Particle> ParVec; > > > > int q1 = -1; > > int q2 = 1; > > float E1=3.0; > > float Px1=1.0; > > float Py1=1.0; > > float Pz1=1.0; > > float E2= 5.0; > > float Px2=1.4; > > float Py2=1.2; > > float Pz2=1.0; > > > > Particle *muon1 = new Particle(q1, E1,Px1,Py1,Pz1); > > Particle *muon2 = new Particle(q2, E2,Px2,Py2,Pz2); > > > > ParVec.push_back(*muon1); > > ParVec.push_back(*muon2); > > > > Dimuon *jpsi = new Dimuon(muon1, muon2); > > DimuVec.push_back(*jpsi); > > > > delete muon1; > > delete muon2; > > delete jpsi; > > > > vector<Particle>::iterator mu1; > > for (mu1 = ParVec.begin(); mu1 < ParVec.end(); ++mu1){ > > cout << "I am here particle iterator loop " << endl; > > } > > > > vector<Dimuon>::iterator dimu; > > for (dimu = DimuVec.begin(); dimu < DimuVec.end(); ++dimu){ > > cout << "I am here Dimuon iterator loop " << endl; > > } > > cout << "DimuVec size= " << DimuVec.size() << endl; > > cout << "ParVec size= " << ParVec.size() << endl; > > > > } > > > > ******************************************** > > > > when I run this marco, I got correct output, at the end of the root > run, > > it crash by segmentation violation. > > > > *************** > > root [0] .L try.C > > root [1] main() > > I am here particle iterator loop > > I am here particle iterator loop > > I am here Dimuon iterator loop > > DimuVec size= 1 > > ParVec size= 2 > > > > *** Break *** segmentation violation > > Root > Function main() busy flag cleared > > **************** > > > > when I trace this root file: I got > > > > ************* > > void destroy(Dimuon* first, Dimuon* last) { > > while (first != last) destroy(first++); > > } > > !!! Reading template destroy > > # 120 "algobase.h" > > 120 > > 121 void destroy(Dimuon* first, Dimuon* last) { > > 122 while (first != last) destroy(first++); > > 123 } > > !!!Complete instantiating template destroy > > > > *** Break *** segmentation violation > > Root > !!!Destroy static member object 0x883f838 > > vector<Particle>::~TRint() !!!Destroy static member object 0x8822e58 > > vector<Dimuon>::~TRint() Function main() busy flag cleared > > ************** > > > > PS: I can do this correctly using standard C++ without CINT, is this > > CINT problem or I did something wrong. > > > > Thanks, > > Xiaorong > > > > > > > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET