Hi, Add #ifdef __MAKECINT__ #pragma link C++ class testTemp<int>+; #endif to your header testio.C file. Cheers, Philippe. -----Original Message----- From: owner-about-root@listserv.fnal.gov [mailto:owner-about-root@listserv.fnal.gov]On Behalf Of j.rademacker1@physics.ox.ac.uk Sent: Thursday, November 11, 2004 1:58 PM To: j.rademacker1@physics.ox.ac.uk Cc: cdf_software_help@fnal.gov; about-root@fnal.gov; roottalk@root.cern.ch Subject: Re: root trees Hi I have more problems with root trees. I want to save templated class. I wrote a little test program that works fine with a normal class, but when I add a template I get the following error message: =========================================================== Processing doTestio.C... Info in <TUnixSystem::ACLiC>: creating shared library /data4/home/rademack/BLife/realBu2/Oxf ordB/root/newStandard/./testio_C.so dlopen error: /data4/home/rademack/BLife/realBu2/OxfordB/root/newStandard/./testio_C.so: und efined symbol: _ZN8testTempIiE11ShowMembersER16TMemberInspectorPc Load Error: Failed to load Dynamic link library /data4/home/rademack/BLife/realBu2/OxfordB/r oot/newStandard/./testio_C.so g++: stdfunc.dll: No such file or directory *** Interpreter error recovered *** Error: Function testio() is not defined in current scope FILE:doTestio.C LINE:9 Possible candidates are... filename line:size busy function type and name *** Interpreter error recovered *** ================================================== This is the program that caused the error message: ================================================== #include "TObject.h" #include "TFile.h" #include "../UHTFitter/UHTPolyWithBool.h" #include <iostream> using namespace std; template<class T> class testTemp : public TObject{ public: T p; ClassDef(testTemp, 1) }; ClassImp(testTemp<int>) void testio(){ testTemp<int> tc; tc.p=25; cout << "p before" << tc.p << endl; TFile fout("test.root", "RECREATE"); fout.cd(); fout.WriteObject(&tc, "tfitter", ""); fout.Close(); TFile fin("test.root"); fin.cd(); testTemp<int>* tc2Ptr; fin.GetObject("tfitter", tc2Ptr); fin.Close(); cout << "p after " << tc2Ptr->p << endl; } ================================================== I have no idea how to solve this - any help would be much appreciated. Thanks a lot! Jonas On Thu, 11 Nov 2004 j.rademacker1@physics.ox.ac.uk wrote: > Hi > > I'm trying to write an object I have to a root file, from within root. I > compile my code with the + option and then run it in batch mode. > > In my class header, I have the ClassDef macro, and in my .C file the > correspondig ClassImp macro. I have that for all classes involved, and > the class I want to save inherits from TObject (other classes that are > members of this one don't inherit from TObject, but I guess that doesn't > matter?). Everything compiles fine. My program even produces a non-empty > output file. But when I want to read it back in, I get the following > run-time error: > > ========================================================== > Warning in <TStreamerInfo::BuildOld>: Cannot convert > UHTDecay::stableParts from type:vector< > UHTTrack> to type:UHTTrkListType, skip element > ========================================================== > > Now UHTTrkListType is just a typedef for std::vector<UHTTrack>. So there > is no conversion to be done. What am I doing wrong? Can I use typedefs > at all? And vectors? If so, how do I get root to know about them? > > Thanks a lot! > > Jonas > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Jonas Rademacker, Denys Wilkinson Bldg, Keble Road, Oxford OX1 3RH, UK > Tel: +44-1865-273410 Fax: +44-1865-273418 > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Jonas Rademacker, Denys Wilkinson Bldg, Keble Road, Oxford OX1 3RH, UK Tel: +44-1865-273410 Fax: +44-1865-273418
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET