Problem with custom RooFit PDF

Dear experts,

I am trying to create a new PDF and use the RooClassFactory for this. However the code generated by this doesn’t link:

g++ test_main.cpp `root-config --libs --glibs --cflags` -lRooFitCore -lRooFit 
/tmp/cc4x49eM.o: In function `__static_initialization_and_destruction_0(int, int)':
test_main.cpp:(.text+0x463): undefined reference to `ROOT::GenerateInitInstance(RooMyPdf const*)'
/tmp/cc4x49eM.o: In function `RooMyPdf::IsA() const':
test_main.cpp:(.text._ZNK8RooMyPdf3IsAEv[_ZNK8RooMyPdf3IsAEv]+0xd): undefined reference to `RooMyPdf::Class()'
/tmp/cc4x49eM.o: In function `RooMyPdf::ShowMembers(TMemberInspector&) const':
test_main.cpp:(.text._ZNK8RooMyPdf11ShowMembersER16TMemberInspector[_ZNK8RooMyPdf11ShowMembersER16TMemberInspector]+0x11): undefined reference to `RooMyPdf::Class()'
/tmp/cc4x49eM.o:(.rodata._ZTV8RooMyPdf[_ZTV8RooMyPdf]+0x1e0): undefined reference to `RooMyPdf::Streamer(TBuffer&)'
/tmp/cc4x49eM.o:(.rodata._ZTV8RooMyPdf[_ZTV8RooMyPdf]+0x660): undefined reference to `non-virtual thunk to RooMyPdf::Streamer(TBuffer&)'
collect2: error: ld returned 1 exit status

When I remove the offending lines:

ClassImp(RooMyPdf); 
ClassDef(RooMyPdf,1) // Your description goes here...

It compiles but then it generates a segfault instead.

./a.out 

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

[#1] INFO:NumericIntegration -- RooRealIntegral::init(test_Int[y]) using numeric integrator RooIntegrator1D to calculate Int(y)
*** Error in `./a.out': free(): invalid pointer: 0x0000000002525254 ***
======= Backtrace: =========

Is there anything wrong with my use of the factory?

Regards,
Albert

I think @moneta can help you with this.

In the meantime, I’ve had similar problems with custom pdf class linking using g++. The way I have gotten around it (inelegantly) is to use a gROOT ProcessLine command in the body of your code (instead of linking).

For example,

  gROOT->ProcessLine(".L RooBkgPdf.cxx+");

Some people in Compiling a RooFit User Pdf with g++ seem to have gotten further, but I haven’t managed to re-create their success yet.

good luck, and if you find a simple solution, please share!
:slight_smile:

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