Problem with libraries autoloading

Hi Rooters,

I am quite a newby with the new 5.16 rootmap mechanism, and
I apologize if the question is silly.

On one hand, I have a ROOT macro which is discovering at runtime the directory where are staying the required libraries, and which is loading them one by one.

On the other hand, the librarians who are generating those directories are trying to take profit from the new autoloading mechanism, and they are providing some rootmap files for each of the libraries.

Let’s consider that for a given job, the discovered directory is D, and there are two libraries within, lib1 and lib2, where lib2 depends on lib1.

My macro is used to load lib1, then lib2, but this is now failing : when it is loading lib2, the autoloading mechanism see the lib2.rootmap file and read within that it depends on lib1. Apparently, it does not understand that lib1 has already been loaded, and it is searching for lib1 within the directories of LD_LIBRARY_PATH, which does not include the directory D…

When one has previously explictly loaded one of the required library, it would be fine if the autoloading mechanism was able to recognize it, and not search it again in LD_LIBRARY_PATH. It would be the perfect fix.

For my problem, I have a short-term fix : I can copy the libraries within a directory under my control, and do not copy the rootmap files. With no rootmap file, my problem vanish.

A better fix would be the ability to add on the fly a given directory (D in my example) to the list of directories where the autoloading is searching for the required libraries. Perhaps there is already a way to do it ?

Any help welcome :wink:

This works with this fix :

 // Upgrade dynamic path so that rootmap required
 // libraries can be found in the directory of
 // the currently loaded library
 TString dynPath = gSystem->GetDynamicPath() ;
dynPath += ":" ;
dynPath += gSystem->DirName(libpath) ;
gSystem->SetDynamicPath(dynPath.Data() ) ;

Whatsoever, I think it should be automatic.
When one #include a file1, if file1 #include another
file2, the first directory where file2 is searched for is
the directory of file1.