R__LOAD_LIBRARY help

Dear Rooters,

I need to include some libraries, that are in a certain path, before running my ROOT macro.

When I ran my code line by line in the ROOT interpreter, starting with:

root [0] .L full-path-to-my-lib/lib1.so 
root [1] .L full-path-to-my-lib/lib2.so
root [2] RecEvent* theRecEvent = new RecEvent(); //RecEvent is defined in one of the libraries.
//...Rest of the code...

then everything worked fine.

Then I dumped the code in a .C file. I replaced the lines where I include the libraries with:

R__ADD_LIBRARY_PATH(full-path-to-my-lib)
R__LOAD_LIBRARY(lib1.so)
R__LOAD_LIBRARY(lib2.so)
RecEvent* theRecEvent = new RecEvent(); //RecEvent is defined in one of the libraries.
//...Rest of the code...

and tried to run it, but the interpreter showed the following type of errors:

Error: Symbol RecEvent is not defined in current scope  myCode.C:10:

I also tried variants including the full-path directly in the R__LOAD_LIBRARY or repeating the R__ADD_LIBRARY_PATH line before the addition of the second library and still failed.

I also want to avoid modifying the .rootlogon.C as I have two versions of ROOT installed, a v.5 and a v.6. I only need to include these libraries for the v.5 and I toggle between versions often.

Could you help me solve this and understand what is going on?
Thank you in advance,
Flavia.


Please read tips for efficient and successful posting and posting code

_ROOT Version: 5.34/38
_Platform: Ubuntu 18.04.2 LTS (bionic)
_Compiler: ROOT CINT


You need a decent ROOT 6 for these macros to be available.

In ROOT 5, you can try:

gSystem->Load("full-path-to-my-lib/lib1.so");
gSystem->Load("full-path-to-my-lib/lib2.so");

or:

gSystem->AddDynamicPath("full-path-to-my-lib");
gSystem->Load("lib1");
gSystem->Load("lib2");

Thank you very much Wile_E_Coyote!