TFile::GetObject() function in Virsual C++ 2008


for some reason I have to port my Linux program using ROOT to windows program. And there I got a problem with the function GetObject(const char* namecycle, void*& ptr). My code looks like following:

TFile* rf = new TFile(name, "update"); TTree* tr; rf->GetObject(treename.c_str(), tr);

When I try to compile the rows by using the compiler of Visual C++ 2008 Express Edition. The complier returns me the error message:

I searched in the system for ‘GetObjectW’. There is a function with the same name in WinGDI.h, which I didn’t included. And we know, GetObject of ROOT is not a direct function from TFile but the ancestor class TDirectory. The Program was running on Linux without any problem. I am really new to windows. Please help me!

Simon Lu


If you try to use ROOT code from a Visual C++ project using standard Windows headers, try to #include “Windows4Root.h” in your source. It should avoid this kind of problem.
You may also want to take a look at examples in $ROOTSYS/test, and especially Makefile.win32 as example of Windows nmake makefile.

Cheers, Bertrand.