Checksum error when trying to save a vector<vector<MyC

Hi, I’m having problems reading a class that contains a vector of vectors of a class that contains a vector of ints (and before you ask, yes I think this is the best solution though I could be wrong).

Everything seems to work beautifully with the MSVC compiled code, reads and writes without any problems; however, when I try to read the created root file in a macro I get the following error (many times):

Error in TBuffer::ReadVersion: Could not find the StreamerInfo with a checksum of ### for the class “vector” in Vehicle.root.

I’m attaching a simplified set of files:
Table (cpp & h) - a simple class with a single vector member.
Vehicle (cpp & h) - the container class that contains a vector<vector

>.
main.cpp - the code that creates and later reads the tree.
tree.C - the macro I’m using to read the tree.

…and some supporting files:
CompileCodes.cpp - a root macro I’m using to create my dlls

I’ve tried writing a custom streamer, but I had the same errors.

Using root version 5.14/00.

Help!

Thanks,
Chris Kunz
vector.tar (20 KB)

Humm … this is odd I am unable to reproduce your problem.
More surprisingly your example seems incomplete since I get (when executing tree.C): Error: Can't call vector<vector<Table,allocator<Table> >,allocator<vector<Table,allocator<Table> > > >::size() in current scope tree.C:32: This is easily solve by adding to Vehicle.cpp:#ifdef __MAKECINT__ #pragma link C++ class vector<Table>; #pragma link C++ class vector<vector<Table> >; #endif(and then I also need to make sure the dict for vector is loaded by doing #include on the command line).
Then I get:[code]bash-3.2$ root.exe -b -
root [0] #include <vect
root [1] .x tree.C
number of cars: 2
Vehicle[0]:parameter=1
vector[0][0][0]=1111
vector[0][0][1]=1112
vector[0][0][2]=1113
vector[0][1][0]=1121
vector[0][1][1]=1122
vector[0][1][2]=1123
vector[0][2][0]=1131
vector[0][2][1]=1132
vector[0][2][2]=1133
vector[1][0][0]=1211
vector[1][0][1]=1212
vector[1][0][2]=1213
vector[1][1][0]=1221
vector[1][1][1]=1222
vector[1][1][2]=1223
vector[1][2][0]=1231
vector[1][2][1]=1232
vector[1][2][2]=1233
vector[2][0][0]=1311
vector[2][0][1]=1312
vector[2][0][2]=1313
vector[2][1][0]=1321
vector[2][1][1]=1322
vector[2][1][2]=1323
vector[2][2][0]=1331
vector[2][2][1]=1332
vector[2][2][2]=1333

Vehicle[1]:parameter=45
vector[0][0][0]=2111
vector[0][0][1]=2112
vector[0][0][2]=2113
vector[0][1][0]=2121
vector[0][1][1]=2122
vector[0][1][2]=2123
vector[0][2][0]=2131
vector[0][2][1]=2132
vector[0][2][2]=2133
vector[1][0][0]=2211
vector[1][0][1]=2212
vector[1][0][2]=2213
vector[1][1][0]=2221
vector[1][1][1]=2222
vector[1][1][2]=2223
vector[1][2][0]=2231
vector[1][2][1]=2232
vector[1][2][2]=2233
vector[2][0][0]=2311
vector[2][0][1]=2312
vector[2][0][2]=2313
vector[2][1][0]=2321
vector[2][1][1]=2322
vector[2][1][2]=2323
vector[2][2][0]=2331
vector[2][2][1]=2332
vector[2][2][2]=2333[/code]

Cheers,
Philippe

Thanks for taking a look at this. I must be doing something wrong. I’ll list exactly what I’m doing below and maybe you can spot my error:

First of all, I’m working in Cygwin under Windows XP, using ROOT version 5.14/00, and Microsoft Visual Studio 8.

  1. run compile.sh (see new attachment)
  2. run main.exe (created from compile.sh)
  3. run root CompileCodes.cpp
  4. move the dlls created from step 3 into the current directory
  5. run root tree.C

Everything seems to work up until step 5. At that point, I get the following:

Any ideas?

Thanks,
Chris
vector_v2.tar (20 KB)

Hi,

In using 2 different build system you inadvertently used 2 version of the ROOT I/O:rootcint -f TableDict.cpp -c Table.hwill request to use the old I/O for the Table class, while the compilation via ACLiC will request to use the new I/O. Because the old I/O is not self describing, we can’t know when looking at a file where it is compatible with the new I/O. Most time it is, sometimes it is not. In particular the support for stl container was inadequate in the old I/O.

So in you compile script you need to request the new I/O for your classes, either adding a trailing ‘+’ at the end of the #pragma link line or in your example simply use:rootcint -f TableDict.cpp -c Table.h+

Cheers,
Philippe

Outstanding. Thank you so much for taking time to look into this. It looks like it’s working.

Thanks,
Chris Kunz