Loading libraries in rootlogon

Hello,

In the post root.cern.ch/drupal/content/way-root-6 you mention that you might have to remove the feature of cint:

What is the alternative. In my rootlogon.C, I do just as above. Do I need to call another macro from rootlogon.C after calling Load(“libEven”) that then creates the Event object, or is there a smarter way to do this?

Keep up the good work.

Cheers,
Whit

Hi,
So far I am not aware of any smarter way. You need to execute gSystem->Load(“libEvent”); before void f() (better in a separate unnamed macro)
Cheers,
Vassil

Hi Vassil,

Thanks for the speedy reply!

How does cling handle unnamed scripts? That is files that look like this

{ /*code here*/ }
compared to scripts like this

void myscript(){
/*code here*/
}

Is .rootlogon.C necessarily unnamed? Or is it just because it starts with a “.”?

Cheers,
Whit

Hi Whit,
The {/code/} is attached to a function declaration. The point is you need to force cling to compile the gSystem->Load(“library”); before you ‘request’ any of the symbols in the library. The way cling works is that instead of compiling/interpreting statement by statement it compiles bigger chunks of code at once such as functions (aka incremental inputs), but not necessarily. Say if you have:
[root] #include “myScript.h” // all this will be compiled in one go
This is why you cannot have the gSystem->Load residing in the same ‘compilation entity’.

Probably what you are looking for is starting root like this:
root -e"gSystem->Load(“MyLib”);"
Cheers,
Vassil

Hi Vassil,

Thank you for the explanation.

[quote]Probably what you are looking for is starting root like this:
root -e"gSystem->Load(“MyLib”);"[/quote]
That is clever. I suppose one could also add an alias like this if they are always used.

Hi,
Absolutely! You could alias the most common invocations.
Cheers,
Vassil

Hi Vassil,

I was looking at root.cern.ch/download/doc/Gettin … ff-scripts trying to use rootalias.C with no success. Then I noticed something about rootlogon.C

I am in my home directory with the files:
[ul]
[li].rootlogon.C - which does gSystem->Load(“lib”)[/li]
[li].rootconfiglib.C - which uses and configures new library[/li]
[li].rootrc[/li][/ul]

#.rootrc file
Rint.Logon:              .rootconfiglib.C

Then if I run root in my home directory, everything goes well!
ROOT runs .rootlogon.C first, followed by .rootconfiglib.C.
But if I am not in $HOME it only runs the .rootlogon.C. This seems to go against the documentation which says [quote]the options are merged, with precedence local, user, global. [/quote]

I guess I could alias root -e "gROOT->ProcessLine(\".x /home/whit/.rootconfiglib.C\");" but that again seems ugly.

It would be quite nice if in addition to .rootlogon.C there was another automatic script which would be for the purpose of loading libraries before the rootlogon.C.

Or better yet, just group the script explicit “chunks”

{
   {
      gSystem->Load("libSomething.so");
   }

   Something *s = new Something();
}

It is legal code that serves no purpose in C++ that i know of.

Cheers,
Whit

Please submit a bug report on that.

I agree that there are plenty of options out there, however this is of low priority in our work plan so it will have to wait probably after 6.0
Cheers,
Vassil

Hi Vassil,

Done. sft.its.cern.ch/jira/browse/ROOT-5855

Also, I found that if I put

at the very end of .rootlogon.C it works. However, if it is not at the end of the script I get the following:

[quote] *** Break *** segmentation violation
Generating stack trace…
0xb5482b65 in
0xb5482b3c in
0xb664e380 in llvm::JIT::runFunction(llvm::Function*, std::vector<llvm::GenericValue, std::allocatorllvm::GenericValue > const&) at JIT.cpp:? from /home/whit/root_build/root/lib/libCling.so
0xb597117c in cling::ExecutionContext::executeFunction(llvm::StringRef, cling::Interpreter&, clang::QualType, cling::StoredValueRef*) + 0x7bc from /home/whit/root_build/root/lib/libCling.so
0xb5934df6 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::StoredValueRef*) + 0xe6 from /home/whit/root_build/root/lib/libCling.so
0xb59380f0 in cling::Interpreter::EvaluateInternal(std::basic_string<char, std::char_traits, std::allocator > const&, cling::CompilationOptions const&, cling::StoredValueRef*, cling::Transaction**) + 0xa0 from /home/whit/root_build/root/lib/libCling.so
0x0997aac0 in
[/quote]

Thanks for your help.

Cheers,
Whit

Hi Whit,
That seems another bug that needs to be investigated. Could you please file that one too.
Many thanks,
Vassil

Done. sft.its.cern.ch/jira/browse/ROOT-5856