GSL/mathmore troubles

Hi,
I am running into troubles with mathmore. And I hope someone here can help.

I need to use GSL random wrappers in mathmore. Specifically I need Multinomial generator which is sadly not a part of TRandom (would be nice btw)

Default build (afs provided) on my system does not include mathmore. So I privately built GSL 1.14 and built root 5.27.04.

This is how I configure root:
./configure --enable-roofit --enable-minuit2 --enable-mathmore --enable-gsl-shared --with-gsl-incdir=/atlas/data3/userdata/wfedorko/myGSL/gslInstall/include --with-gsl-libdir=/atlas/data3/userdata/wfedorko/myGSL/gslInstall/lib

If I don’t do --enable-gsl-shared configure complains that libgslcblas wasn’t compiled with -fPIC (even though it WAS!!! I checked the compilation log) and mathmore won’t get built.

Then In my executable I do:

#include “Math/GSLRndmEngines.h”
#if not defined(CINT)
#include “Math/Random.h”
#endif

…(in main)

ROOT::Math::RandomROOT::Math::GSLRngMT GSLr;

vector sigexp_extravar_thisbin=GSLr.Multinomial(exp_nsig,sigprob_extravar_thisbin);

in my makefile:

ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
ROOTLDFLAGS := $(shell root-config --nonew --ldflags)

CXX = g++
CXXFLAGS = -g --exceptions -I…/stringutils -I…/ControlFileParser -I…/HistoUtils -I …/MLUtils -I$(PWD) -I$(ROOTCFLAGS) -O2

LIBS = -lm -lControlFileParser -lstringutils -lHistoUtils -lMLUtils -lRooFit -lRooFitCore -lFoam -lMinuit -lgsl -lgslcblas

LDFLAGS = $(ROOTLDFLAGS) $(ROOTLIBS) $(ROOTGLIBS) $(LIBS) -L…/ControlFileParser -L…/stringutils -L…/HistoUtils -L…/MLUtils -L/atlas/data3/userdata/wfedorko/myGSL/gslInstall/lib -O2

%.exe : %.cxx $(OBJS)
@echo building exe $@
@$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(patsubst %.exe,%.cxx, $@) $(LDFLAGS)

When I try to build this I get a bunch of linker errors:

-bash-3.2$ make
building exe runPE_drawhist_testvar_multivar.exe
runPE_drawhist_testvar_multivar.cxx: In function ‘int main(int, char**)’:
runPE_drawhist_testvar_multivar.cxx:528: warning: passing ‘Double_t’ for argument 3 to ‘RooDataSet* generatePseudoData(TH2F*, int, int, RooArgSet&)’
runPE_drawhist_testvar_multivar.cxx:538: warning: passing ‘Double_t’ for argument 3 to ‘RooDataSet* generatePseudoData(TH2F*, int, int, RooArgSet&)’
runPE_drawhist_testvar_multivar.cxx:547: warning: passing ‘Double_t’ for argument 3 to ‘RooDataSet* generatePseudoData(TH2F*, int, int, RooArgSet&)’
runPE_drawhist_testvar_multivar.cxx:571: warning: passing ‘Double_t’ for argument 1 to ‘std::vector<unsigned int, std::allocator > ROOT::Math::Random::Multinomial(unsigned int, const std::vector<double, std::allocator >&) [with Engine = ROOT::Math:]’
runPE_drawhist_testvar_multivar.cxx:578: warning: passing ‘Double_t’ for argument 1 to ‘std::vector<unsigned int, std::allocator > ROOT::Math::Random::Multinomial(unsigned int, const std::vector<double, std::allocator >&) [with Engine = ROOT::Math:]’
runPE_drawhist_testvar_multivar.cxx:585: warning: passing ‘Double_t’ for argument 1 to ‘std::vector<unsigned int, std::allocator > ROOT::Math::Random::Multinomial(unsigned int, const std::vector<double, std::allocator >&) [with Engine = ROOT::Math:]’
/tmp/ccRZTavn.o: In function Random': /atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/Random.h:68: undefined reference toROOT::Math::GSLRngMT::GSLRngMT()’
/atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/Random.h:69: undefined reference to ROOT::Math::GSLRandomEngine::Initialize()' /tmp/ccRZTavn.o: In functionROOT::Math::RandomROOT::Math::GSLRngMT::Multinomial(unsigned int, std::vector<double, std::allocator > const&)’:
/atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/Random.h:277: undefined reference to ROOT::Math::GSLRandomEngine::Multinomial(unsigned int, std::vector<double, std::allocator<double> > const&) const' /atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/Random.h:277: undefined reference toROOT::Math::GSLRandomEngine::Multinomial(unsigned int, std::vector<double, std::allocator > const&) const’
/atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/Random.h:277: undefined reference to ROOT::Math::GSLRandomEngine::Multinomial(unsigned int, std::vector<double, std::allocator<double> > const&) const' /tmp/ccRZTavn.o: In function~Random’:
/atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/Random.h:97: undefined reference to ROOT::Math::GSLRandomEngine::Terminate()' /tmp/ccRZTavn.o: In function~GSLRngMT’:
/atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/GSLRndmEngines.h:265: undefined reference to ROOT::Math::GSLRandomEngine::~GSLRandomEngine()' /tmp/ccRZTavn.o: In function~Random’:
/atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/Random.h:97: undefined reference to ROOT::Math::GSLRandomEngine::Terminate()' /tmp/ccRZTavn.o: In function~GSLRngMT’:
/atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/GSLRndmEngines.h:265: undefined reference to ROOT::Math::GSLRandomEngine::~GSLRandomEngine()' /atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/GSLRndmEngines.h:265: undefined reference toROOT::Math::GSLRandomEngine::~GSLRandomEngine()’
/atlas/data3/userdata/wfedorko/myroot/root-5.27.04/include/Math/GSLRndmEngines.h:265: undefined reference to ROOT::Math::GSLRandomEngine::~GSLRandomEngine()' /tmp/ccRZTavn.o:(.rodata._ZTIN4ROOT4Math8GSLRngMTE[typeinfo for ROOT::Math:]+0x10): undefined reference totypeinfo for ROOT::Math::GSLRandomEngine’
collect2: ld returned 1 exit status
make: *** [runPE_drawhist_testvar_multivar.exe] Error 1

I understand the warnings in the compilation - but I don’t think they are relevant.
Can anyone help me with this? What is this /tmp/ccRZTavn.o??? How do I make it work?

Thanks,
Wojtek

Hi,

you need to link against libRootMore. See the “library:” line in the little box on the top right at root.cern.ch/root/html/ROOT__Math__GSLRngMT.html

Cheers, Axel.

Thanks - that works,
Wojtek