This is the easiest way to compile a .cxx code but can be used only for the histogram and trigger codes used during data acquisition and analysis. Other than that, use one of the methods described in the next sections.
To compile an analysis code, just load the .cxx file in the ScanRoot or SPMRoot programs. The file will be automatically compiled and loaded in memory. In this case, the files need to follow some simple rules that can be found in this link.
Compiling a single c++ program
To compile a single root macro, just type in the prompt:
compileMacro macro.cxx
where macro.cxx is the name of your macro. A shared library named macro.so will be generated automatically and can be loaded into root with the command:
gSystem->Load("macro.so");
Compiling a directory with multiple files and classes definitions
After your analysis class have been written it is necessary to compile it in order to boost performance. In general, a few rules should be followed in order to use the general compiler tool that is part of this package.
All library files should be in a single directory. That does not mean you can't have multiple libraries in different directories but the compiler tool compiles only one directory at once
All c++ header files should have .h extension
All c++ code files should have a .cxx extension
You should have a file named LinkDef.h. This file is necessary to create a CINT dictionary file for ROOT. If there is NO LinkDef.h file, the macro will automatically create one but with limited functionality. Click here for instructions on how to create a LinkDef.h file if necessary.
To compile the code type:
compile LIBNAME [INPUTDIR] [OUTPUTDIR]
where:
LIBNAME is the library name of the compiled code. File will be named as LIBNAME.so
[INPUTDIR] is the directory where source file is saved. The default value is the current directory
[OUTPUTDIR] is the directory where the library file is going to be saved. The default value is the current directory
LinkDef.h
The structure of the LinkDef.h file is basically:
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#ifdef __CINT__
#pragma link C++ class NAME1+;
#pragma link C++ function NAME2+;
...
...
...
#endif
where NAME1, NAME2, NAME3 are the name of the classes, function, templates, enumerators, etc... you have defined and want to create root dictionary.
Only classes, functions, etc that have a dictionary created can be used in a non-compiled macro or in the root prompt.
Classes, functions, enumerators, etc that will have a dictionary generated should have prototypes defined in a .h file, otherwise the compiler will not be able to create the dictionary.
Here is the list of all #pragma directives you can have in the rootCint
#pragma link C++ class ClassName[-];
#pragma link C class ClassName;
#pragma link off class ClassName;
#pragma link C++ enum ClassName;
#pragma link C enum ClassName;
#pragma link off enum ClassName;
#pragma link C++ function FuncName;
#pragma link C function FuncName;
#pragma link off function FuncName;
#pragma link C++ global VariableName;
#pragma link C global VariableName;
#pragma link off global VariableName;
#pragma link C++ typedef TypeName;
#pragma link C typedef TypeName;
#pragma link off typedef TypeName;
#pragma link off all classes;
#pragma link off all functions;
#pragma link off all variables;
#pragma link off all typedefs;
admin (version 3.01): Both men and women are wo… Appannababu (Make your questio…): Hello Patrico,
Thanks, I … Patricio Carnelli… (Make your questio…): Hi Appannababu,
This scri… Appannababu (Make your questio…): Hello,
I am new t… cheap nashville p… (Using Graphical C…): Thanks for your sharing.i… Supra Skytop (version 3.01): This topic was really edu… Supra Sneakers (Using Graphical C…): Hey, appreciate it for ta… Patricio Carnelli… (Make your questio…): Hello,
I’m a PhD student … Bob (Pivot 1.30 Beta 2…): And this is what a commen…