[ROOT] Embedding root

From: ruediger@tau.ep1.ruhr-uni-bochum.de
Date: Thu Jun 12 2003 - 18:18:55 MEST


Hi there,

I'm trying to embed root into a C++ application in the following way:
In the constructor of a class I call

myInterpreter = new TRint("ROOT population", NULL, NULL);

myInterpreter is defined as TRint * in the same class. A function of that
class is then supposed to repeatedly execute root scripts like this :

gROOT->ProcessLine(Form(".x
%s(%p,%d,%p)",rootScript.c_str(),values,size_this,&result),&error);

"values" is a double array of size size_this, result is a double. I'm
using
the following example script, it is stored in a file parabola.cc (the same
name is stored in the string "rootScript", see above).

void parabola(double *values, int nValues, double *result)
{
  int i;

  *result=0;
  for(i=0; i<nValues; i++)
    *result += values[i]*values[i];
}

Executing my application results in the following error message :

[...]
CINT/ROOT C/C++ Interpreter version 5.15.74, Feb 2 2003
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
Error: Function parabola(0xbfffd8d0,2,0xbfffda38) is not defined in
current
scope  FILE: LINE:0
Possible candidates are...
filename       line:size busy function type and name
parabola.cc       1:8    0 public: void parabola(double* values,int
nValues,double* result);
[...]

If I do the same directly in root, namely :

root [0] double values[2]={2.,2.};
root [1] double result;
root [2] int size_this = 2;
root [3] .x parabola.cc(values,size_this,&result);
root [4] cout << result << endl;
8

I get back the correct result.

Any help is appreciated !

Have a nice day,
Ruediger Berlich



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET