Weird Type casting

I’m trying to get a tree out of o root file, but it doesn’t work at all. I tried to do this with the interpreter and it works fine, but when i try to do it visual c++ 6 it acts weirdly. Here is what i done and what happens:

TTree *tree =(TTree *)(gDirectory->Get(“h51”));

This should work out fine i hoped but when i print it (tree->Print()) this is the result:

Error in TBuffer::CheckByteCount: object of class TNamed read too few bytes: 2
6 instead of 2103413
Warning in TBuffer::CheckByteCount: TNamed::Streamer() not in sync with data o
n file, fix Streamer()
OBJ: TNamed :heart:h51 Atl

Now it’s a TNamed object, how could this happen?

Hi,

This is usually happens when you have not linked against the libTree library.

Cheers,
Philippe.

Thanks for the answer Phillippe, you are awesome.

Anyhow, I actually already added it into the worksapce. Do i need to do anything else than that?

Hi,
if adding libTree to the project doesn’t help you should add the libraries to your link line. See the second half of http://root.cern.ch/phpBB2/viewtopic.php?t=1640.
Axel.