Compiled macros for different root versions


I typically compile (if necessary) and load several homegrown utilities libraries by doing, e.g.,

gROOT->ProcessLine(".L mylib.C+");

in my rootlogon.C file.

This works OK except that lately I have to work with multiple root versions. In this case the utility libraries are recompiled whenever I switch root versions. This can occur when I’m running different jobs on a large cluster. I wonder if there is a known solution to my problem.

In other words, is it possible to:

(a) still keep a single source directory for my utilties
(b) have multiple build directories, such that the one actually used by root is dependent on the root version?

I can imagine other strategies (such as one like the soversion option available when building root) but don’t know if I’m facing an already solved problem. Any help appreciated!

mike kordosky

Hi Mike,

you might be able to piece a solution together using TSystem::CompileMacro()'s build dir parameter, which you set to something depending on TROOT::GetVersion() (remember to replace the dangerous characters). Please let me know if these hints are insufficient.

Cheers, Axel.

When I need this kind of setup I use the following in my rootlogon.C:

TString dirname = gROOT->GetVersion(); dirname.ReplaceAll(".","-"); dirname.ReplaceAll("/","-"); dirname.Append(".libs"); gSystem->SetBuildDir(dirname);Cheers,

Hi guys,

Using your excellent advice I was able to come up with:

/////////////  root/loon version dependent compilation //////////////////////
// this allows you to use multiple root versions on the same system
// without libraries constantly being recompiled.
TString dirname = gROOT->GetVersion();
TString appname(gApplication->Argv(0));
else appname="root";
dirname.Prepend("/root_build/"); // base dir for compliled macros
cout<<"Setting build directory to: "<<dirname<<endl>mkdir(dirname.Data(),true); // make dir if it doesn't exist


It does exactly what I wanted and so simple!


mike kordosky