Can't add a new roofit class to root with cmake

I’m trying to add a new class to root, specifically adding a new pdf shape to roofit, RooDoubleCBShape, which I have inherited the .cxx and .hpp files for. I have got this working via a makefile, so I am certain that this code does work. I am now trying to get it working in cmake as opposed to make, and am running into some issues.
While I can build this with no errors and produce an executable, when that executable reaches a line involving this class, e.g. w->factory("RooDoubleCBShape::cb_shape(mB,mean,sigma,alpha,n,beta,l)"); it crashes completely. I’ve done my best to follow working examples online, but so far I’ve had little success. If I run ldd on the executable, I can see all the root libraries I expect (libCore.so, libRooFitCore.so, etc), but not the library that I generate here (libRooDoubleCBShape.so). If I change to a different shape (e.g. RooGaussian), it runs with no errors.

My code is below, the overall layout is: individual_fitter.cpp/hpp is a class which can perform a fit, and fitter.cpp creates an instance of this class (with certain arguments) and contains the main() function. All .cpp/.cxx files are in the src directory, and all .hpp/.h files are in include
CMakeLists.txt:

cmake_minimum_required(VERSION 3.7.0)
project(fitter)

find_package(ROOT COMPONENTS RooFit RooStats RooFitCore)
include(${ROOT_USE_FILE})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
ROOT_GENERATE_DICTIONARY(RooDoubleCBShape_Dict include/RooDoubleCBShape.hpp LINKDEF include/DictLinkDef.h)

add_library(RooDoubleCBShape SHARED src/RooDoubleCBShape.cxx RooDoubleCBShape_Dict)                                                            
target_include_directories(RooDoubleCBShape PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(RooDoubleCBShape PUBLIC ${ROOT_LIBRARIES})

add_executable(individual_fitter src/fitter.cpp src/individual_fitter.cpp) 
target_link_libraries(individual_fitter RooDoubleCBShape) #RooDoubleCBShape has ROOT_LIBRARIES in it

DictLinkDef.h (without the include/, libRooDoubleCBShape_Dict.rootmap is empty):

#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;

#pragma link C++ defined_in "include/RooDoubleCBShape.hpp"; 

#endif

Does anyone have any idea what is wrong here? If there’s any other parts of my code that are needed I’m happy to share them. Running this generates all the files I expect (libRooDoubleCBShape_Dict_rdict.pcm,libRooDoubleCBShape_Dict.rootmap,libRooDoubleCBShape.so,RooDoubleCBShape_Dict.cxx), and I can’t work out from my code why the RooDoubleCBShape hasn’t got into the executable

ROOT Version: 6.22/02
Platform: Centos7
Compiler: Through lb-conda (lhcb)

@oshadura do you know what’s going on? Thanks!

Can you please post here what actually is generated in the build directory (.pcm, .so and etc. files)?

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