You are here

How To Create a Dictionary?

A dictionary is a source file that once compiled, linked into a library or executable and loaded into a process will give to ROOT's interpreter all the information it needs about a type or variable. A dictionary is essential for a C++ entity to be streamed in or out of a ROOT file.

You have 3 options to create a dictionary.

Use ACLiC to generate the dictionary for everything defined in a source or header file:

root [] .L myScript.cxx+

or (from compiled code):

gROOT->ProcessLine(".L myScript.cxx+")
To generate the dictionary for a single class or for a class template instance use:
gInterpreter->GenerateDictionary("map<string,Track>","Track.h;map");
gInterpreter->GenerateDictionary("myclass","myheader.h");
To generate the dictionary from a Makefile, you can use the following rule to generate a dictionary for the headers $(HEADERS) and a library containing the dictionary and the compiled $(SOURCES):
MyDict.cxx: $(HEADERS) Linkdef.h
[TAB]     rootcling -f $@ -c `root-config --cflags` -p $^
 
libMyLib.so: MyDict.cxx $(SOURCES)
[TAB]     g++ -shared -o$@ `root-config --ldflags` $^

See Interacting with Shared Libraries: rootcling for more details.