With Cling, we parse the script before executing its content. This means that if the library load is done inside main.C then the symbol ExRootTreeReader is seen (and complained about) before the library is even attempted to be loaded.
You have 3 additional work around (in addition to the extra script):
(a) transform main.C from an unnamed macro to a named macro (i.e. you need to give a name to the function, usually the same as the file name) and add at the beginning of the file (so that it is handled at parsing time):
(b) Generate a rootmap file for your library and add its location/directory to the LD_LIBRARY_PATH to enable auto-loading.
( c ) Use the tip of the main development branch or the soon to be released v6.24/00 and just add the location/directory of the library to the LD_LIBRARY_PATH to enable the new library auto-loading mechanism.
As a result, if I do
root libscript.C
the root prompt yields the following error:
/lhef_helper.h:16:10: fatal error: ‘HepMC3/LHEF.h’ file not found #include “HepMC3/LHEF.h” // LHEF::HEPEUP
Before running root, I redefined all of ROOTSYS, PATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH so that they include . I didn’t know/remember which one was the right one, so I tried with all of them. Apparently, none is the right one.
How should I instruct the root prompt to look into ?
More generally, what are the paths that ROOT looks into, in case of