ROOT user define function and compile use gcc

i follow some instruction like $ROOTSYS/tutorials/fit/myfit.C

but how do i use user define function when i compile it use gcc, not in root cinit

Double_t FitFunc(Double_t *x, Double_t *par)   //fit reject the sig and bad 
{
  Double_t v = 0;
  
  if ( reject_flag && reject_h &&  (x[0] >=reject_below && x[0] < reject_above)  ) {
    TF1::RejectPoint();
    //return 0;
  } else {
    switch(poly){
      case 1: v = par[0] + par[1]*x[0];
      case 2: v = par[0] + par[1]*x[0]+par[2]*pow(x[0],2);
      case 3: v = par[0] + par[1]*x[0]+par[2]*pow(x[0],2)+par[3]*pow(x[0],3);
      case 4: v = par[0] + par[1]*x[0]+par[2]*pow(x[0],2)+par[3]*pow(x[0],3)+par[4]*pow(x[0],4);

  }
  }
  
  return v;
}

it works when use : root: .x $ROOTSYS/tutorials/fit/myfit.C

but when do compile use gcc ** , it could not find function declared in this scope, any suggestion? for use user define function link to compile.

Thanks

You have to create a dictionary. Best option: .L yourCode.C+ (note the trailing “+”). That does the necessary and then invokes the compiler.

Axel.

It’s works ,Thanks a lot ~

Ping[quote=“Axel, post:2, topic:24217, full:true”]
You have to create a dictionary. Best option: .L yourCode.C+ (note the trailing “+”). That does the necessary and then invokes the compiler.

Axel.
[/quote]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.