Is that code actually executed when loading the library?
Yes.
The line of gInterpreter->Declare("#include \"AOpticsManager.h\"");
is executed right after the library is manually or automatically loaded because of the GCC or Clang’s functionality of __attribute__((constructor))
.
Is the library loaded before loading the script?
No.
When I do not load my library before loading or executing my script, as you know, the library loading process is of course automatically done.
I tried three different cases.
- NG
root [0] .x test.C
root [1] #include "AOpticsManager.h"
root [2] .x test.C
- OK
root [0] #include "AOpticsManager.h"
root [1] .x test.C
root [2] .x test.C
- OK
root [0] gSystem->Load("libROBAST")
root [1] .x test.C
root [2] .x test.C
From your explanation in the threads, I understand why cases 2 and 3 work because the root [0]
line in both cases loads the library first. But I do not understand why the 1st case does NOT work, while inserting #include
in the script resolves the issue.