Undefined reference to `ROOT::Math::GSLMinimizer::GSLMinimizer(ROOT::Math::EGSLMinimizerType)

Dear Rooters:
I am try to using GSLMinimizer to do some work, when I try to compile my code with gcc, I got:

[zwang@login01 script]$ make -f Makefile_DoUnfolding
root-config --cxx -fPIC -w -g -o DoUnfolding DoUnfolding.C -L./src/ -L/home/ams/zwang/public/Analysis/TrappedNuclei/AlbertoBT/AMS/lib/root-config --arch6.22 -lntuple_slc6_PG_dynamic -D_PGTRACK_ -isystem/home/ams/zwang/public/Analysis/TrappedNuclei/AlbertoBT/AMS/include -isystem/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.06/x86_64-centos7-gcc48-opt/include -isystem./src -I. root-config --libs -lc -lMinuit
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /tmp/ccGEBrHf.o: in function ForwardUnfold::NumericalMinimizationLogxLogyMC(int, double)': /home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1006: undefined reference to ROOT::Math::GSLMinimizer::GSLMinimizer(ROOT::Math::EGSLMinimizerType)’
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1025: undefined reference to ROOT::Math::GSLMinimizer::SetFunction(ROOT::Math::IBaseFunctionMultiDimTempl<double> const&)' /cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1031: undefined reference to ROOT::Math::BasicMinimizer::SetVariable(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, double, double)’
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1039: undefined reference to ROOT::Math::GSLMinimizer::Minimize()' /cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1006: undefined reference to ROOT::Math::GSLMinimizer::~GSLMinimizer()’
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1006: undefined reference to `ROOT::Math::GSLMinimizer::~GSLMinimizer()’
collect2: error: ld returned 1 exit status
make: *** [DoUnfolding] Error 1

Any clue for this??
Thanks in advance.
Zhaomin

_ROOT Version:6.22.06
_Platform:x86_64-centos7
_Compiler:gcc 9.3.0


Welcome to the ROOT Forum! It looks like -lMathMore is missing

Thanks for this swift response.
It helps with most parts, now seems only one problem left:

[zwang@login01 script]$ make -f Makefile_DoUnfolding
root-config --cxx -fPIC -w -g -o DoUnfolding DoUnfolding.C -L./src/ -L/home/ams/zwang/public/Analysis/TrappedNuclei/AlbertoBT/AMS/lib/root-config --arch6.22 -lntuple_slc6_PG_dynamic -D_PGTRACK_ -isystem/home/ams/zwang/public/Analysis/TrappedNuclei/AlbertoBT/AMS/include -isystem/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.06/x86_64-centos7-gcc48-opt/include -isystem./src -I. root-config --libs -lc -lMinuit -lMathMore
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /tmp/ccMcrKBG.o: in function `ForwardUnfold::NumericalMinimizationLogxLogyMC(int, double)’:
/home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1031:

undefined reference to `ROOT::Math::BasicMinimizer::SetVariable(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, double, double)’

collect2: error: ld returned 1 exit status
make: *** [DoUnfolding] Error 1

Anything more should I add??
Thanks a lot.
Zhaomin

Try using root-config --cflags to have the same flags than ROOT (e.g. for the c++ standard version, like -std=c++14)

Hi,
root-config --cflags gives:
[zwang@login01 script]$ root-config --cflags

-pthread -std=c++11 -m64 -I/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.06/x86_64-centos7-gcc48-opt/include

so the C++ 11 is being used, Is this means it is out of data and should be changed into C++ 14 in root configuration??
Thanks,
Zhaomin

No, that simply means that the compiler supports c++11

I am a little bit confused now, Could you please offer me more details about " Try using root-config --cflags to have the same flags than ROOT (e.g. for the c++ standard version, like -std=c++14 )" ??
Best,
Zhaomin

The same way you are using root-config --libs, simply add root-config --cflags

I replaced the “root-config --libs” with “root-config --libs --cflags” but the problem is still there:

root-config --cxx -fPIC -w -g -o DoUnfolding DoUnfolding.C -L./src/ -L/home/ams/zwang/public/Analysis/TrappedNuclei/AlbertoBT/AMS/lib/root-config --arch6.22 -lntuple_slc6_PG_dynamic -D_PGTRACK_ -isystem/home/ams/zwang/public/Analysis/TrappedNuclei/AlbertoBT/AMS/include -isystem/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.06/x86_64-centos7-gcc48-opt/include -isystem./src -I. root-config --libs --cflags -lc -lMinuit -lMathMore
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /tmp/ccMGRxkt.o: in function ForwardUnfold::NumericalMinimizationLogxLogyMC(int, double)': /home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1031: undefined reference to ROOT::Math::BasicMinimizer::SetVariable(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, double, double)’
collect2: error: ld returned 1 exit status
make: *** [DoUnfolding] Error 1

Any clues?
Best,

Don’t replace root-config --libs. Try with:

`root-config --cxx --cflags` -fPIC -w -g -o DoUnfolding DoUnfolding.C -L./src/ ... `root-config --libs` -lMinuit -lMathMore

see for example Using ROOT in a c++ code - #2 by Wile_E_Coyote

Hi, Bellenot
I tried it, but still:
root-config --cxx --cflags -fPIC -w -g root-config --cflags -o DoUnfolding DoUnfolding.C -L./src/ -L/home/ams/zwang/public/Analysis/TrappedNuclei/AlbertoBT/AMS/lib/root-config --arch6.22 -lntuple_slc6_PG_dynamic -D_PGTRACK_ -isystem/home/ams/zwang/public/Analysis/TrappedNuclei/AlbertoBT/AMS/include -isystem/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.06/x86_64-centos7-gcc48-opt/include -isystem./src -I. -lc -lMinuit -lMathMore root-config --libs
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /tmp/ccaiG7hU.o: in function ForwardUnfold::NumericalMinimizationLogxLogyMC(int, double)': /home/ams/zwang/AMS/ana/NiFlux/analisi/script/ForwardUnfolding4.h:1030: undefined reference to ROOT::Math::BasicMinimizer::SetVariable(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, double, double)’
collect2: error: ld returned 1 exit status
make: *** [DoUnfolding] Error 1
:thinking:
I am actually not use BasicMinimizer directly in the code, I used GSLMinimizer which is inherited from BasciMinimizer, will this give some clues?

Best,

As edited by @Pepe_Le_Pew (thanks!) try with

`root-config --cxx --cflags` -fPIC -w -g -o DoUnfolding DoUnfolding.C -L./src/ ... `root-config --libs` -lMinuit -lMathMore

Or try to add the -std=c++11 flag

Sorry for being annoying, still:

`root-config --cxx --cflags` -fPIC -w -g -o DoUnfolding DoUnfolding.C -L./src/… `root-config --libs` -lMinuit -lMathMore -lMinuit2
/cvmfs/sft.cern.ch/lcg/releases/binutils/2.34-990b2/x86_64-centos7/bin/ld: /tmp/cc6voNrC.o: in function ‘ForwardUnfold::NumericalMinimizationLogxLogyMC(int, double)’:
/home/ams/zwang/ForwardUnfolding4.h:1030: undefined reference to `ROOT::Math::BasicMinimizer::SetVariable(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, double, double)`
collect2: error: ld returned 1 exit status
make: *** [DoUnfolding] Error 1

The -std=c++11 flag is already included in the root-config --cflags.
Best,

Then I don’t know what could be the issue… Maybe @moneta has an idea

Attach your “ForwardUnfolding4.h” for inspection.

Hi, all
After I reinstalled the newest root version, It’s done!
I don’t know why, but everything works.
Thank you all again for the valuable help.
Best