Unloading? a library or loading a library again?


On another thread we discussed how to load a custom library when executing a script. A solution was proposed that worked for the first execution of the script, but upon a repeated execution the script failed:

I was asked to open a new thread to discuss the issue, so here it is.



Unloading is still not fully supported, to the extent we’re aiming for, in ROOT 6. Your best options is sadly to quit ROOT and start again.

I have added a bug report to track this: https://sft.its.cern.ch/jira/browse/ROOT-8745

Cheers, Axel.

Thanks for starting the bug report.

Is there a way to somehow just avoid reloading the library and simply using what was previously loaded? Some sort of if statement wrapped around like the following nonworking example:


Hmm - I’m not sure it’s the library loading that’s causing this.

Even if you do

.x scriptAfterRemovingR__LOAD_LIBRARY.C
.x scriptAfterRemovingR__LOAD_LIBRARY.C

it might still fail, and likely the same way…


And why is that? There is some underlying mechanics here that I don’t understand.

Because reloading of that script fails. It works for some, fails for some, and we’re going to make lots of progress on it this year (we have a couple of crucial pull requests pending on that already).


1 Like

Alright, Thanks for the info. I’ll hold my breath and see whats coming.

For now I’ve stepped around the problem by having two macros. The first loads the library and the second does the work. I can reload the second ad nauseum without any issues.

/// Loading script, load this only once.
   gSystem->ProcessLine(".L workMacro.C");
// Work macro, can be reloaded with `.L workMacro.c`
void workMacro() {
   //Do some work
 if (!TClassTable::GetDict("TFoo")) {

This doesn’t quite resolve the issue, and brings us back to the previous thread: Loading a library from a script

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.