How to create a global variable like gPad

Dear Rooters,

I am trying to create a program that has a class which allows me to update Histograms. I would like to access this class from the command line via a global variable like gPad.
Please see the attachment for an example. Here I create an instance of the class which I assign to a global variable. But when I want to access this global variable I get the following:

[code] *******************************************

  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.28/00 14 December 2010 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      http://root.cern.ch            *
    
  •                                     *
    

ROOT 5.28/00 (trunk@37585, Dec 14 2010, 15:20:27 on linuxx8664gcc)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] gHistUpdater
Error: Symbol gHistUpdater is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
[/code]

what do I need to do to be able to access the global variable?

Thank you,
Lutz
exampleForRoot.tar.gz (15.3 KB)

VIVE L’AMOUR!
search the Internet for “c++ singleton”.
For example:
en.wikipedia.org/wiki/Singleton_pattern
yolinux.com/TUTORIALS/C++Singleton.html
devarticles.com/c/a/Cplusplu … ern-Part-I
codeproject.com/KB/cpp/singletonrvs.aspx
sourcemaking.com/design_patterns/singleton/cpp/1
infernodevelopment.com/singleton-c
See also the implementation of some singletons (e.g. gPad, gROOT, gSystem, …) in ROOT.
If the only thing you want is to access your variable “gHistUpdater” from the interpreter, add the following line to your “linkdef.h” file:

#pragma link C++ global gHistUpdater;

I am stupid. No?
Pepe Le Pew.

Hi,

and you have to first load the library before you can use globals from it. You can also use the singleton approach that Pepe suggests and create a static member function of some class. That allows you to use the class name in a rootmap file (e.g. created with rlibmap) which will trigger automatic loading of your library.

Cheers, Axel.