RE: Compiling vs loading library libEvent.so : USE the ROOT SCRIPTCOMPILER

From: Philippe Canal (pcanal@fnal.gov)
Date: Wed Jan 26 2000 - 18:26:52 MET


Hi,

Just one more usefull feature of the script compiler is that it is
totally machine independent.  The exact same .L foo.cc++ creates
a shared on Linux, Osf1, sgi, etc... with any change and any maintenance
of many complex makefiles.

Philippe.

-----Original Message-----
From: Philippe Canal [mailto:pcanal@fnal.gov]
Sent: Wednesday, January 26, 2000 6:22 PM
To: Christian Holm Christensen; Rene.Brun@cern.ch
Cc: roottalk@pcroot.cern.ch
Subject: RE: Compiling vs loading library libEvent.so : USE the ROOT
SCRIPTCOMPILER


Hi Christian,

You mentionned:

	Why not just shift to your
	terminal, create a dynamicly loadable object:

	  > g++ -fPIC -g -O2 -c foo.cc -o foo.o
	  > g++ -Wl,-soname,foo.so -o foo.so foo.o

	shift back to ROOT, load the object

          root [1234] gSystem->Load("foo.so");

This technique does not make any of your symbols available to the
cint interpreter.  So eventhough over compiled code would be able
to access your functions or classes, you will not be able to create,
or call them, directly from the root/cint prompt.

The missing step is calling rootcint:

	rootcint -f fooDict.cc -c foo.h fooLinkDef.h

In the fooLinkDef.h you have to list what you want to make availaible
to cint. (and do not forget to compile and link those).

In addition, the script compiler takes care of making sure you
are compiling with the same options as the current root.  This
is essential in most case to be able to load the shared library.

For example if root is compiled with --with-thread=-lpthread,
at least on some platform, you HAVE TO compile you library with it.

In most case, I also prefer to have complete control of the make process.

However the script compiler provide you with a fast, low maintenance way
of compiling small scripts and load them immediately.  (this way I do not
have to write a makefile for every single test script I ever write).

In addition the Script Compiler let you customize the build process in
the most obvious way (see TSystem::SetIncludePath and a few more explained
in the documentation of TSystem::CompileMacro
http://root.cern.ch/root/html/TSystem.html#TSystem:CompileMacro ).

So in summary the Script Compiler is the easy for those of us that prefer
to avoid makefile when they can, to quickly compile and load a c++ files.

Philippe.



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET