Issue with class inheritance


Normally I don’t have any compiler issues for class inheritance with TObject. But now I would like to inherit RooAbsPdf in order to create PDFs that can be used by RooFit.


[code]#ifndef ROOTEST
#define ROOTEST

#include “RooRealProxy.h”
#include “RooAbsReal.h”
#include “RooAbsPdf.h”
#include “TObject.h”

class RooTest : public RooAbsPdf {
RooTest() {} ;
RooTest(const RooTest& other, const char* name=0) ;
// virtual TObject* clone(const char* newname) const { return new RooTest(*this,newname); }
inline virtual ~RooTest() { }

Double_t evaluate() const ;

ClassDef(RooTest,1) // Your description goes here…



[code] #include “RooTest.h”


RooTest::RooTest(const RooTest& other, const char* name) :
RooAbsPdf(other,name) {

Double_t RooTest::evaluate() const {
return (0.5);

I am receiving a compiling error. Here is the beginning of the output from ‘make’:

[quote]/usr/bin/c++ -O2 -pipe -Wall -W -Woverloaded-virtual -m64 -I/Users/ericwhite/root_v34/include -c -o RooTest.o RooTest.C
Generating dictionary …
/usr/bin/c++ -O2 -pipe -Wall -W -Woverloaded-virtual -m64 -I/Users/ericwhite/root_v34/include -c -o eventdict.o eventdict.C
/usr/bin/c++ -dynamiclib -single_module -install_name /Users/ericwhite/Desktop/work/rootest4/ -O2 -mmacosx-version-min=10.8 -m64 RooTest.o eventdict.o -o -L/Users/ericwhite/root_v34/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lm -ldl -L/Users/ericwhite/root_v34/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lm -ldl
Undefined symbols for architecture x86_64:
“RooAbsReal::createChi2(RooDataSet&, RooCmdArg const&, RooCmdArg const&, RooCmdArg const&, RooCmdArg const&, RooCmdArg const&, RooCmdArg const&, RooCmdArg const&, RooCmdArg const&)”, referenced from:
vtable for RooTest in RooTest.o[/quote]

(I have attached full logfile and Makefile.) This error does NOT happen with ACLiC, I get no errors when I open Root and type “.L RooTest.C+”.

You may ask “why not just use ACLiC”? The reason is that I plan to write several classes, so I need to be able to compile them all at once (which can be done with a Makefile). I don’t know if there is any way to create a shared library for many files using the ACLiC method (".L [many classes here]+").

I am running version 5.34/14 on MacBook Pro (OSX 10.8.5). Thank you for any help.
Makefile.txt (1.53 KB)
log.txt (14.8 KB)


the linker is complaining since it cannot find the symbol associated to RooAbsReal::CreateChi2.
You should link with “-l RooFitCore”.


Hi Danilo,

Thank you very much for the quick reply, I strongly suspect that will solve things. My problem is that I do not understand makefiles very well… could you please look at the one attached in the first post and tell me where/what I should add?

Also, I would like the output to be a single *.so file that can be loaded into Root. Will your suggestion fix my problem both for compiling and create the shared library? Thanks so much.

Much appreciated!

Thanks again, after some testing and inspecting, I decide to place the flag in the following line of my Makefile:

Seems to work!

Thanks again so much.