load shared library in compiled sourcecode

From: Stephan Zimmer <zimmerst_at_googlemail.com>
Date: Thu, 29 Oct 2009 18:46:14 +0100


Hi ROOTers,
again I need your help. I want to access routines that are linked through the shared library from the MadEvent ExRootAnalysis package libExRootAnalysis.so within a compiled sourcecode. I have a control-file which I load with root -l MyMacro.C
---->

#include <math.h>
#include <iostream>
#include <TMath.h>
#include <TFile.h>
#include <TH1.h>
#include <TControlBar.h>

void Analyzer(){

   gSystem->Load("libExRootAnalysis");
   gROOT->ProcessLine(".L analysis.C+");    TString fname = "myfile.root";
   analysis(fname);
----<
and the corresponding analysis.C - file:
---->

# include <all the other classes i need> using namespace std;
void analysis(TString fname){
 TFile *f_data= new TFile(fname+".root","READ");  TTree *STDHEP = (TTree*)f_data->Get("STDHEP");  ExRootTreeReader *treeReader = new ExRootTreeReader(STDHEP);  TClonesArray *particles = treeReader->UseBranch("GenParticle"); ...
}
----<
and a corresponding header file analysis.h
---->

# include <all the other classes i need> using namespace std;
void analysis(TString fname)
----<
As long as I use the gSystem->Load-Statement and just interpret my code, everything is fine, but as soon as I use this way to run the analysis.C in a compiled version, CINT/ROOT complains that the ExRootTreeReader is not defined in the current scope (ExRootTreeReader) is a class inside the library I load with the load-statement. More generally it is about loading shared libraries into compiled code but specifically I want to use the ExRootAnalysis package provided by MadEvent. Thank you *very* much for your helpful support! Cheers,
Stephan Received on Thu Oct 29 2009 - 18:46:30 CET

This archive was generated by hypermail 2.2.0 : Thu Oct 29 2009 - 23:50:02 CET