Problem with reading TH2D drawn in mode COLZ from root file


I discovered a problem with the read routine of TFile. I have created a TH2D which I drew in mode “COLZ”. This histogram is stored in a canvas and written to file. This .root file is opened in a second program. But it does already give me a strange error when I call the constructor of TFile:

std::string filename = "/tmp/root2.root";
TFile* rootFile = new TFile(filename.c_str());

This produces this error msg:

Warning in <TClass::TClass>: no dictionary for class TPaletteAxis is available

Reading the canvas now:

TCanvas* readCan = 0;

produces the following errors:

Error in <TBufferFile::ReadObject>: trying to read an emulated class (TPaletteAxis) to store in a compiled pointer (TObject)
Error in <TList::AddLast>: argument is a null pointer

After a lot of tries and different approaches I found a workaround: If one creates an instance of TCanvas before opening the file, everything is ok. I don’t think is intended to work that way.

I have written a simple demo program for this. If it is called with any two parameters (argc=3)
it creates a root file with a TH2D in a canvas.
If it is called w/o any parameters, it reads the file and fails.
If it is called with 1 parameter, it creates a dummy canvas before reading the file and succeeds .

One more note on this: If the TH2D is drawn via mode “BOX” this problem doesn’t occur. I use root 5.18 etch.
RootProblem.cxx (1.45 KB)

This problem was fixed about one year ago. Move to a more recent version (ie 5.20)


Did you verify this being fixed with root 5.18 or 5.20? I have now installed 5.20, changed the env variables to the new version, made a clean build and I still see the same behaviour of my demo program.

I tested your example with 5.20


I was really puzzled when I read your answer. I converted my source file (which I compile with g++) into a root macro - and it works.

Conclusion: I can confirm it working as root macro (root .x RootProblem.c) but it still fails if compiled via g++ 4.1.2.

I can live with creating a dummy canvas in the first lines of my code, it’s just a report of what happens and doesn’t seem to work as intended.
RootProblem.c (1.34 KB)


I see the same error with compiled code and the same ROOT version. Normally these warnings can be removed by adding another library to the link line. For example, TreePlayer is not included in the ROOT 5.22/00j version of

root-config --libs

but is required to remove one of the dictionary warnings. Therefore, perhaps a ROOT expert can suggest which library or LinkDef.h entry might remove this warning?

Thanks and Best Regards,



To remove these warning from compiled code the link line should include


in addition to the libraries returned by

root-config --libs