Not able to reference ROOT::Math:: Factory::CreateMinimizer (despite it working in CINT)

Dear all,

I am trying to compile some ROOT code which references a ROOT::Math::Factory::CreateMinimizer object but get the following compilation error:

../fitter/libfitter.so.1.0.0: undefined reference to `ROOT::Math::Factory::CreateMinimizer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
../errprop/liberrprop.so.1.0.0: undefined reference to `TString::TString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
../utils/libxslfutils.so.1.0.0: undefined reference to `YAML::LoadFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status

However, I am able to create the ROOT::Math::Factory object with CINT:

$ root -l
root [0] m = ROOT::Math::Factory::CreateMinimizer()
(ROOT::Math::Minimizer *) @0x7ffe5eaf7020
root [1]

The code I am trying to compile is this one:
https://gitlab.com/cuddandr/xsLLhFitter/-/tree/ND280UpFit_generalizedSampleDefinition

Does anyone know how I can start to solve this?
Many thanks in advance!


ROOT Version: 6.18.04
Platform: LCG_94/x86_64-centos7-gcc7-opt
Compiler: cmake version 3.11.1


Hi,

It looks to me as a configuration problem with building your tool with cmake. When building you need to add the dependency on the ROOT core libraries, like libCore and libMathCore. Did you define ROOTSYS when building your fitter tool ?

Lorenzo

Thank you for your help!
I get the following when I run $ROOTSYS/bin/root-config --libs:

-L/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.04/x86_64-centos7-gcc48-opt/lib
-lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree
-lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread
-lMultiProc -lROOTDataFrame -pthread -lm -ldl -rdynamic

Do you know if this includes the right libraries? Otherwise, how would I add them?

Hi,

Yes this are the right libraries. But you need to include them in the CMakefiles. You are not using ROOT as a package, like for example in this repo, https://github.com/root-project/rootbench, but adding by using the output of root-config.
Are you sure the libraries are propagated correctly when linking ?

Lorenzo

I think they are included in the CMakefile. Here is the part of it that is dealing with ROOT:

# ROOT
if ( NOT DEFINED ENV{ROOTSYS} )
  cmessage(FATAL_ERROR "$ROOTSYS is not defined, please set up root first.")
else()
  cmessage(STATUS "Using ROOT installed at $ENV{ROOTSYS}")
  set(CMAKE_ROOTSYS $ENV{ROOTSYS})
endif()

#If you want to try an use the terminally buggy ROOT CMake scripts
if (USEROOTCMAKE)
  include ($ENV{ROOTSYS}/etc/cmake/FindROOT.cmake)
  if ( NOT ROOT_FOUND )
    cmessage(FATAL_ERROR "[ROOT]: FindROOT.cmake could not be found, or did not execute as expected is ROOT installed in $ROOTSYS = $ENV{ROOTSYS}?")
  endif()
else()
  cmessage(STATUS "Including local GENERATE_ROOT_DICTIONARY implementation.")
  include(${CMAKE_SOURCE_DIR}/cmake/GenROOTDictionary.cmake)
endif()

execute_process (COMMAND root-config --cflags OUTPUT_VARIABLE ROOT_CXX_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND root-config --libs OUTPUT_VARIABLE ROOT_LD_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND root-config --version OUTPUT_VARIABLE ROOT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
cmessage(STATUS "[ROOT]: root-config --version: ${ROOT_VERSION}")
cmessage(STATUS "[ROOT]: root-config --cflags: ${ROOT_CXX_FLAGS}")
cmessage(STATUS "[ROOT]: root-config --libs: ${ROOT_LD_FLAGS}")

and the output when I run it:

-- [INFO]: Using ROOT installed at /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.04/x86_64-centos7-gcc48-opt
-- [INFO]: Including local GENERATE_ROOT_DICTIONARY implementation.
-- [INFO]: Added ROOT_GENERATE_DICTIONARY CMake macro.
-- [INFO]: [ROOT]: root-config --version: 6.18/04
-- [INFO]: [ROOT]: root-config --cflags: -pthread -std=c++11 -m64 -I/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.04/x86_64-centos7-gcc48-opt/include
-- [INFO]: [ROOT]: root-config --libs: -L/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.04/x86_64-centos7-gcc48-opt/lib -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -pthread -lm -ldl -rdynamic

which lists the same libraries as before. Would this mean that it’s included correctly? Do you know what else I could check?

Many thanks for your help!
Best,
Caspar

Try compiling with verbose, make VERBOSE=1

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