RE: Library auto-loading

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Wed, 14 Dec 2005 22:47:56 -0600


Hi Jerome,

In addition, you can add some code to check whether the library is alrady loaded before attempting to load your custom version.

Cheers,
Philippe.

-----Original Message-----

From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Philippe Canal
Sent: Wednesday, December 14, 2005 10:07 PM To: 'Jerome LAURET'; roottalk_at_pcroot.cern.ch Subject: RE: [ROOT] Library auto-loading

Hi Jerome,

The choice we made so far is that any time we see the 'mention' of class we look it up and load the corresponding library. Doint anything smarter would require us to also known the context in which the name is mention (not impossible but a little bit tricky ... since in particular the lookup has to be done __before__ a statement is fully parse).

Anyway the way I usually deal with this type of case is to have 2 macro. One in charge of the loading and one containing the code. The advantage of this, is that I can seamlessly move from interpreted to compiled. For example my loader script looks like:

// loader.C
{

   gSystem->Load("libMyclasses.so");
   gROOT->ProcessLine(".L myscript.C");
}

Another alternative is to leverage the autoloader and tell him to load your library instead. For example you could prepend $HOME/pythia6 to your LD_LIBRARY_PATH. If the library name is different from the default name, then you have to write your own .rootmap file.

Cheers,
Philippe

-----Original Message-----

From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Jerome LAURET
Sent: Monday, December 12, 2005 9:32 PM
To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] Library auto-loading

        While debugging a variant of
$ROOTSYS/exmples/pythiaExample.C, I came across a side effect of library loading. The macro contained one more function

Bool_t Charged(TMCParticle *p)

    While CINT interpreted the macro, interpretation of TMCParticle loaded libEG.so, libEGPythia.so and libPythia.so respectively even BEFORE the macro entry point was called. Whenever the equivalent of pythiaExample() was called and subsequentely loadLibraries(), the gSystem->Load("$HOME/pythia6/libPythia6") did not do anything (the default installed libPythia6 was already loaded) making it impossible to debug a private version of libPythia6 [unless redefinition of LD_LIBRARY_PATH or similar which may not always be applicable].

        This behavior may potentially be confusing to users. Forward declaration of TMCParticle did not help by the way: the loading still occured contrary to expectations. Is this a known feature or is this a bug ??

        This is seen in 4.04.02 which has the additional known issue of needing a different variant of libPythia6 than previous ROOT versions ...

-- 
              ,,,,,
             ( o o )
          --m---U---m--
              Jerome
Received on Thu Dec 15 2005 - 05:49:56 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:14 MET