Add library in root by default?


I would like to setup my library in root or at least in my /usr/local/ directory.
I moved my .h in /usr/local/include ; and my shared library .so in /usr/local/lib

I loaded my #include <MyClass.h>, in my ROOT code since MyClass.h is in a default location; but I don’t know how to load by default my .so library

I noticed that root-config --lib contain libraries by default. I guess it is done at the compilation of ROOT, so I cannot really add my library right ? In other words, do I have to load each time by hand my library ?


Hi Marco,

it’s not clear what you mean by “setup my library in root”: do you want a library to be loaded each time you start root?
If yes in principle this is not a great idea as it can bite back for example when updating root.
Maybe you can allow root to autoload it?


Autoload it, yes exactly! You are right, it’s better i think…
I was using a rootlogon.C file, but I would not use it anymore…
There is something to do with root-config to allow this ?

Edit : Btw I looked at this function “gSystem->GetDynamicPath();”. I got this :

root [1] cout << gSystem->GetDynamicPath() ; .:/opt/local/libexec/root6/lib/root::/usr/local/lib:/usr/X11R6/lib:/usr/lib:/lib:/lib/x86_64-linux-gnu:/usr/local/lib64:/usr/lib64:/lib64:

My library is working if I load .L /usr/local/lib/; so I don’t understand why it is not loaded by default !


(I assume ROOT6)
you need to create a rootmap and leave it in the directory where the library and related pcm are located.
So, concretely:

# within a directory where you want to leave your library
genreflex myheader.h -s myselectionfile.xml --rootmap libMyLibrary.rootmap
g++ -o libMyLibrary.rootmap myheader_rflx.cxx `root-config --cflags --libs` -fPIC -shared



Thanks a lot for all those informations, it’s really helpful.
I just have few more questions. The way to generate this rootmap, does it depend on root5 or root6 ?

Do you have an example of selectionfile.xml ?
I noticed that the rootmap is overwritten each time I use the command for each header file in my library.
It would not be better to do it by hand since it’s just textfile ?


there are small differences between 5 and 6: rootcling -h and genrelfex --help will give you all details.
My advice would be to generate all maps automatically: they are human readable but not really intended for manual modifications.
The command genreflex --help will give plenty of details about the options available and the structure of a selection xml.