Undefined reference to `RooRealVar::RooRealVar(char const*, char const*, double, double, char const*)

Dear All

I have a third-party library contained in the file libRooFitCore.so. The library contains, among other things, a class called RooRealVar. My code declares several objects of this kind. My compile file has this line which included
g++ -Wno-deprecated $1 -o $2 -I$ROOTSYS/include -L$ROOTSYS/lib `root-config --cflags` `root-config --libs`

In my c++ script(find below) I have included RooRealvar.h file also, but still when I try to compile, it shows error:

/tmp/ccFBvssz.o: In function `main':
Fitter.C:(.text+0xe89): undefined reference to `RooRealVar::RooRealVar(char const*, char const*, double, double, char const*)'
Fitter.C:(.text+0xe95): undefined reference to `RooRealVar::~RooRealVar()'
collect2: ld returned 1 exit status

Please suggest what's going wrong here?


Fitter.C Script

#include <iostream>
#include "Zee.C"
#include "TTree.h"
#include "TH1D.h"
#include "TRandom.h"
#include "RooRealVar.h"
using namespace RooFit ;
TH1* makeTH1() ;

int main(){
TH1* hh = makeTH1() ;
RooRealVar x("x","M_{ee} (in GeV)",60,120) ;


This is a linker error, not a compiler error. Have you checked that you compiled ROOT with RooStat enabled?

This really is a question about setting up ROOT and RooStat correctly. It isn't about C++. If you don't figure it out yourself, you should ask this question in the ROOT forum called roottalk. When it is back up again in a few days you can follow the link on root.cern.ch.

Topic archived. No new replies allowed.