gROOT is null. Can someone help?

Hi,
I’m a beginner in ROOT. I use visual studio 2010 and I try to dynamically load the needed ROOT libs into my program.

here is a code fragment from my code.

#include <TROOT.h>
int foo() {
gROOT->Reset();
}
The call to gROOT->Reset() fails because the gROOT var is null. Can you please help me understand why ?
I’ve loaded libCore.lib into the program and I was able to create some other classes.

Please help…
Thanks
Idan

Hi Idan,

I do not know how gROOT could null as it is initialized when libCore.dll is loaded. However you should also never call gROOT->Reset() from within a function ; it is intended to be used only in unnamed macros.

Philippe.

If I add TApplication::CreateApplication(); to the code before using gROOT than everything is working fine.
Can someone explain me why? is it the right thing to do?

Thanks
Idan

Hi,

There is an order of initialization problem (probably induced by the way you link you application). The call to TApplication::CreateApplication force the creation of the TROOT object and thus the setting of gROOT.

Philippe.