On Wed, 26 Jan 2000, Mark James Boland wrote: > Hello ROOT useres, > > I have a macro to do my analysis using ROOT but I would like to speed it > up by compiling it into an executable. My analysis macro uses a library > libEvent.so which I load with the statement > > gSystem.Load("libEvent.so");// Load event and scaler classes > > How do I include this library when compiling? Hi Mark, 2 possibilities: 1.) $ROOTSYS/test contains a worked example: Event, in the Makefile you could replace the line $(LD) $(LDFLAGS) $(MAINEVENTO) $(EVENTLIB) $(LIBS) $(OutPutOpt) $(EVENT) by $(LD) $(LDFLAGS) $(MAINEVENTO) $(EVENTSO) $(LIBS) $(OutPutOpt) $(EVENT) i.e. using the shared lib instead of the obj. 2. from root 2.23/09 onwards you can do: assume the following simple macro (I use again $ROOTSYS/test/libEvent.so) //------------- tevent.C ------------------------------------------------- #include "iostream.h" #include "Event.h" void analyze(){ cout << "analyze(), create an event" << endl; Event * ev = new Event(); ev->SetHeader(1, 12345, 5678, 0.1); ev->Print(); cout << "analyze: RunNr: " << ev->GetHeader()->GetRun() << endl; } //------------------------------------------------------------------- then run root: root [1] gSystem.Load("libEvent.so") (int)0 root [2] .L tevent.C++ Creating shared library /home/rg/schaileo/myroot/test/./tevent.so root [3] analyze() Enter analyze() OBJ: Event Event Event structure analyze: RunNr: 12345 root [4] with this a shared library will be created using the native c++ compiler, analyze() is part of it. (I am on Linux, RH 6.0, root 2.23/11) This is just a very simple example, you may include your own classes, provided you include the ClassDef and ClassImp macros. Cheers Otto ---------------------------------------------------------------------------- Otto Schaile Sektion Physik der LMU Muenchen Phone: (+49 89)289 14070 Am Coulombwall 1, D-85748 Garching, Germany FAX: (+49 89)289 14072 EMail: Otto.Schaile@Physik.Uni-Muenchen.DE
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET