RooFFTConvPdf problem with shared library

Hello guys,

I have a problem related to the RooFFTConvPdf class when I use it through a personal shared library (in this shared library I have a class with a RooFFTConvPdf object as argument). Basically, I am able to compile and build my library without any kind of error or warning. However, when I try to load it through the root shell by using gSystem->Load(“libNAMELIB.so”) I get the error

cling::DynamicLibraryManager::loadLibrary(): dir/lib/libNAMELIB.so: undefined symbol: _ZTI13RooFFTConvPdf

and when I try to run a c++ code, this code is executed correctly with the following error at the end of the program:

*** glibc detected *** NAMEC++EXECUTABLE: munmap_chunk(): invalid pointer: 0x00000000038d49f0 *** ======= Backtrace: ========= /lib64/libc.so.6(+0x75f4e)[0x7fc79e6dcf4e] /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libRooFitCore.so(_ZN9RooArgSet7cleanupEv+0x29)[0x7fc7a16f18a9] /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libRooFitCore.so(+0x39b1cf)[0x7fc7a18451cf] /lib64/libc.so.6(__cxa_finalize+0x9d)[0x7fc79e69cebd] /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libRooFitCore.so(+0x1be946)[0x7fc7a1668946] ======= Memory map: ======== 00400000-00401000 r-xp 00000000 00:13 1357011600 dir/lib/libNAMELIB.so 00601000-00602000 rw-p 00001000 00:13 1357011600 dir/lib/libNAMELIB.so 02240000-04575000 rw-p 00000000 00:00 0 [heap] 7fc7918a1000-7fc79195e000 r-xp 00000000 00:19 176269074 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libMinuit2.so 7fc79195e000-7fc791b5e000 ---p 000bd000 00:19 176269074 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libMinuit2.so 7fc791b5e000-7fc791b62000 rw-p 000bd000 00:19 176269074 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libMinuit2.so 7fc791b62000-7fc791b64000 rw-p 00000000 00:00 0 7fc791b64000-7fc791b84000 r-xp 00000000 fc:01 837322 /lib64/ld-2.12.so 7fc791b84000-7fc791d83000 ---p 00020000 fc:01 837322 /lib64/ld-2.12.so 7fc791d83000-7fc791d84000 r--p 0001f000 fc:01 837322 /lib64/ld-2.12.so 7fc791d84000-7fc791d85000 rw-p 00020000 fc:01 837322 /lib64/ld-2.12.so 7fc791d85000-7fc791d86000 rw-p 00000000 00:00 0 7fc791d86000-7fc791d98000 r-xp 00000000 00:00 0 7fc791e08000-7fc791e32000 r-xp 00000000 00:00 0 7fc791e32000-7fc791e9a000 rw-p 00000000 00:00 0 7fc791f80000-7fc7927b3000 rw-p 00000000 00:00 0 7fc7927b3000-7fc7989cc000 r--p 00000000 00:19 176268068 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/etc/allDict.cxx.pch 7fc7989cc000-7fc7989d2000 r-xp 00000000 00:19 175726341 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/Gcc/gcc484_x86_64_slc6/slc6/x86_64-slc6-gcc48-opt/lib64/libatomic.so.1.0.0 7fc7989d2000-7fc798bd1000 ---p 00006000 00:19 175726341 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/Gcc/gcc484_x86_64_slc6/slc6/x86_64-slc6-gcc48-opt/lib64/libatomic.so.1.0.0 7fc798bd1000-7fc798bd2000 rw-p 00005000 00:19 175726341 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/Gcc/gcc484_x86_64_slc6/slc6/x86_64-slc6-gcc48-opt/lib64/libatomic.so.1.0.0 7fc798bd2000-7fc798bd3000 rw-p 00000000 00:00 0 7fc798bd3000-7fc798bda000 r-xp 00000000 fc:01 808513 /lib64/librt-2.12.so 7fc798bda000-7fc798dd9000 ---p 00007000 fc:01 808513 /lib64/librt-2.12.so 7fc798dd9000-7fc798dda000 r--p 00006000 fc:01 808513 /lib64/librt-2.12.so 7fc798dda000-7fc798ddb000 rw-p 00007000 fc:01 808513 /lib64/librt-2.12.so 7fc798ddb000-7fc798df8000 r-xp 00000000 fc:01 826013 /lib64/libtinfo.so.5.7 7fc798df8000-7fc798ff7000 ---p 0001d000 fc:01 826013 /lib64/libtinfo.so.5.7 7fc798ff7000-7fc798ffb000 rw-p 0001c000 fc:01 826013 /lib64/libtinfo.so.5.7 7fc798ffb000-7fc798ffc000 rw-p 00000000 00:00 0 7fc798ffc000-7fc79acd2000 r-xp 00000000 00:19 176269098 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libCling.so 7fc79acd2000-7fc79aed1000 ---p 01cd6000 00:19 176269098 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libCling.so 7fc79aed1000-7fc79b014000 rw-p 01cd5000 00:19 176269098 /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.10-x86_64-slc6-gcc48-opt/lib/libCling.so 7fc79b014000-7fc79b021000 rw-p 00000000 00:00 0 7fc79b021000-7fc79b826000 r--s 00000000 fc:02 132544 /var/lib/sss/mc/passwd 7fc79b826000-7fc79b82e000 r-xp 00000000 fc:01 786486 /lib64/libnss_sss.so.2 7fc79b82e000-7fc79ba2d000 ---p 00008000 fc:01 786486 /lib64/libnss_sss.so.2 7fc79ba2d000-7fc79ba2e000 rw-p 00007000 fc:01 786486 /lib64/libnss_sss.so.2 7fc79ba2e000-7fc79ba3a000 r-xp 00000000 fc:01 786465 /lib64/libnss_files-2.12.so 7fc79ba3a000-7fc79bc3a000 ---p 0000c000 fc:01 786465 /lib64/libnss_files-2.12.so 7fc79bc3a000-7fc79bc3b000 r--p 0000c000 fc:01 786465 /lib64/libnss_files-2.12.so 7fc79bc3b000-7fc79bc3c000 rw-p 0000d000 fc:01 786465 /lib64/libnss_files-2.12.so 7fc79bc3c000-7fc79bc59000 r-xp 00000000 fc:01 826032 /lib64/libselinux.so.1 7fc79bc59000-7fc79be58000 ---p 0001d000 fc:01 826032 /lib64/libselinux.so.1 7fc79be58000-7fc79be59000 r--p 0001c000 fc:01 826032 /lib64/libselinux.so.1 7fc79be59000-7fc79be5a000 rw-p 0001d000 fc:01 826032 /lib64/libselinux.so.1 7fc79be5a000-7fc79be5b000 rw-p 00000000 00:00 0 7fc79be5b000-7fc79be71000 r-xp 00000000 fc:01 786676 /lib64/libresolv-2.12.so 7fc79be71000-7fc79c071000 ---p 00016000 fc:01 786676 /lib64/libresolv-2.12.so 7fc79c071000-7fc79c072000 r--p 00016000 fc:01 786676 /lib64/libresolv-2.12.so 7fc79c072000-7fc79c073000 rw-p 00017000 fc:01 786676 /lib64/libresolv-2.12.so 7fc79c073000-7fc79c075000 rw-p 00000000 00:00 0 7fc79c075000-7fc79c077000 r-xp 00000000 fc:01 791878 /lib64/libkeyutils.so.1.3Aborted (core dumped)
Does anyone know what can cause this issue? Thank you very much in advance.

Hi,

the problem you have is that the library containing the RooFFTConvPdf, i.e. libRooFitCore.so, must be loaded already when you load your library.
There are at least two ways of achieving this:

  1. When you build your library, you link it against libRooFitCore.so
  2. You make sure that libRooFitCore is already loaded when your library is loaded at runtime explicitly, e.g. by loading it before by hand.
    I would recommend to go for 1).
    As for the second error you paste, hard to say, especially before fixing the first one.

Danilo

Hi Danilo,

Thank you very much for your fast reply!! In principle, I was convinced to already link libRooFitCore.so and libRooFit.so since I am using the following flag in my Makefile:

Anyway, when I try to load manually libRooFitCore.so and libRooFit.so (I need to load manually this library since I am using also a RooGaussModel in my code) before libNAMELIB.so this latter is perfectly loaded! It is obvious now that the libraries linking in my Makefile is not properly done. What it’s wrong in my Makefile? Here my code:

[code]EXE1 = PROGRAM_NAME.cc

#OS Version
ROOTCONFIG := $(ROOTSYS)/bin/root-config
ROOTCINT := $(ROOTSYS)/bin/rootcint
ARCH := $(shell $(ROOTCONFIG) --arch)
PLATFORM := $(shell $(ROOTCONFIG) --platform)

Compiler version

CC = g++

Primary directory

MAINDIR = $(PWD)

Directories

OBJ = obj
DICT = dict
LIB = lib
BIN = bin
SRC = src
MAIN = main
IMG = img
RES = res
FILES = files

Directory commands

RMDIRS = @rm -rf $(OBJ); rm -rf $(DICT); rm -rf $(LIB); rm -rf $(BIN)
MKOBJ = @mkdir -p $(OBJ)
MKDICT = @mkdir -p $(DICT)
MKLIB = @mkdir -p $(LIB)
MKBIN = @mkdir -p $(BIN)
MKUSR = @mkdir -p $(IMG); mkdir -p $(RES); mkdir -p $(FILES)

Include directories

FHH = $(MAINDIR)/$(SRC)
ROOTHH = $(ROOTSYS)/include

ROOT library directory

ROOTSO = $(ROOTSYS)/lib

#RooFit library
RFSO = $(ROOTSO)

File lists

CCLIST = $(wildcard $(FHH)/.cpp)
HHLIST = $(wildcard $(FHH)/
.h)
OBJLIST = $(notdir $(patsubst %.cpp,%.o,$(CCLIST)))
DICTLIST = $(notdir $(patsubst %.h,%Dict.o,$(HHLIST)))

Output name files

LIBNAME = NAMELIB
LIBF = $(MAINDIR)/$(LIB)/lib$(LIBNAME).so

Compiler options

CCOPT = -std=c++11 -O2
CCWARN = -Wall -Wno-deprecated -Wno-write-strings -Wformat -Wsign-compare
CCINCL = -I. -I$(FHH) $(ROOTCONFIG) --cflags -fPIC
CCLIBSO = -L$(RFSO) $(ROOTCONFIG) --libs -lFFTW -lRooFitCore -lRooFit -lRooStats -lHtml -lMinuit -lThread -lTreePlayer -lFoam
-lProof -lProofBench -lProofDraw -lProofPlayer

default: $(BIN)/$(EXE1)

$(LNDIRS)

$(DICT)/%Dict.cpp:
@echo “Making $@”
$(MKDICT)
@$(ROOTCINT) -f $@ -c $(patsubst $(DICT)/%Dict.cpp,$(FHH)/%.h,$@)

$(DICT)/%Dict.o: $(DICT)/%Dict.cpp
@echo “Compiling $@”
$(MKDICT)
@$(CC) $(CCOPT) $(CCWARN) $(CCINCL) -c $(patsubst %.o,%.cpp,$@) -o $@

$(OBJ)/%.o: $(FHH)/%.cpp $(FHH)/%.h
@echo “Compiling $(notdir $(patsubst %.o,%.cpp,$@))”
$(MKOBJ)
@$(CC) $(CCOPT) $(CCWARN) $(CCINCL) -c $(FHH)/$(notdir $(patsubst %.o,%.cpp,$@)) -o $@

$(LIBF): $(addprefix $(OBJ)/, $(OBJLIST)) $(addprefix $(DICT)/, $(DICTLIST)) $(OBJ)/$(LIBNAME)_dict.o
@echo “Make libraries”
$(MKLIB)
$(CC) $(CCOPT) $(CCWARN) $(addprefix $(OBJ)/, $(OBJLIST)) $(addprefix $(DICT)/, $(DICTLIST)) $(SOFLAGS) -o $(LIBF)

$(OBJ)/$(LIBNAME)_dict.o: $(OBJ)/$(LIBNAME)_dict.cxx

$(OBJ)/$(LIBNAME)_dict.cxx: $(wildcard $(FHH)/*.h) $(DICT)/$(LIBNAME)_dict.h $(DICT)/$(LIBNAME)_LinkDef.h
$(ROOTCINT) -f $@ -c -I$(SRC) -I$(DICT) $(DICT)/$(LIBNAME)_dict.h $(DICT)/$(LIBNAME)_LinkDef.h

$(BIN)/$(EXE1): $(MAIN)/$(EXE1).cc $(LIBF)
@echo “Make exe1”
$(MKUSR)
$(MKBIN)
$(CC) $(CCOPT) $(CCWARN) $(CCINCL) -L$(PWD)/$(LIB) $(CCLIBSO) -l$(LIBNAME) $(MAIN)/$(EXE1).cc -o $(BIN)/$(EXE1)
[/code]
Thank you very much.
Marco

Hi Marco,

before diving in the makefile, did you verify that the roofit library is not actually linked to your library with the ldd command?

D

Hi Danilo,

I didn’t know the ldd command (very useful! thank you very much!) and indeed the libRooFitCore.so and libRooFit.so were not correctly linked in libNAMELIB.so. This because I didn’t add the $(CCLIBSO) variable in the Makefile line associated to the compilation of $(LIBF). Now, both c++ executable and library are executed and loaded correctly!

Thank you very much for your help!

Marco