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

**URL:** <https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322>\
**Category:** ROOT\
**Tags:** math\
**Created:** [January 10, 2022, 8:01am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322 "2022-01-10T08:01:44Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhaom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/97f17d/32.png) [@Zhaom](https://root-forum.cern.ch/u/Zhaom)\
**Post date:** [January 10, 2022, 8:01am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/1 "2022-01-10T08:01:44Z")

</div>

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 --arch`6.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

* * *

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 10, 2022, 8:05am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/2 "2022-01-10T08:05:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zhaom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/97f17d/32.png) [@Zhaom](https://root-forum.cern.ch/u/Zhaom)\
**Post date:** [January 10, 2022, 8:23am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/3 "2022-01-10T08:23:50Z")

</div>

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 --arch`6.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

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 10, 2022, 8:30am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/4 "2022-01-10T08:30:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zhaom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/97f17d/32.png) [@Zhaom](https://root-forum.cern.ch/u/Zhaom)\
**Post date:** [January 10, 2022, 9:39am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/5 "2022-01-10T09:39:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 10, 2022, 9:43am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/6 "2022-01-10T09:43:16Z")

</div>

> [@Zhaom](#):
>
> 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??

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

---

<div class="post-metadata">

**Author:** ![Zhaom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/97f17d/32.png) [@Zhaom](https://root-forum.cern.ch/u/Zhaom)\
**Post date:** [January 10, 2022, 10:19am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/7 "2022-01-10T10:19:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 10, 2022, 10:22am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/8 "2022-01-10T10:22:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zhaom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/97f17d/32.png) [@Zhaom](https://root-forum.cern.ch/u/Zhaom)\
**Post date:** [January 10, 2022, 10:38am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/10 "2022-01-10T10:38:44Z")

</div>

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 --arch`6.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,

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 10, 2022, 10:48am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/11 "2022-01-10T10:48:55Z")

</div>

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

```auto
`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](https://root-forum.cern.ch/t/using-root-in-a-c-code/48257/2)

---

<div class="post-metadata">

**Author:** ![Zhaom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/97f17d/32.png) [@Zhaom](https://root-forum.cern.ch/u/Zhaom)\
**Post date:** [January 10, 2022, 12:10pm UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/12 "2022-01-10T12:10:14Z")

</div>

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 --arch`6.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  
🤔  
I am actually not use BasicMinimizer directly in the code, I used GSLMinimizer which is inherited from BasciMinimizer, will this give some clues?

Best,

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 10, 2022, 12:17pm UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/13 "2022-01-10T12:17:07Z")

</div>

As edited by @Pepe_Le_Pew (thanks!) try with

```auto
`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

---

<div class="post-metadata">

**Author:** ![Zhaom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/97f17d/32.png) [@Zhaom](https://root-forum.cern.ch/u/Zhaom)\
**Post date:** [January 11, 2022, 2:41am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/14 "2022-01-11T02:41:02Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 11, 2022, 7:25am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/15 "2022-01-11T07:25:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 11, 2022, 8:50am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/16 "2022-01-11T08:50:06Z")

</div>

Attach your “`ForwardUnfolding4.h`” for inspection.

---

<div class="post-metadata">

**Author:** ![Zhaom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/97f17d/32.png) [@Zhaom](https://root-forum.cern.ch/u/Zhaom)\
**Post date:** [January 12, 2022, 1:41am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/18 "2022-01-12T01:41:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [January 26, 2022, 1:41am UTC](https://root-forum.cern.ch/t/undefined-reference-to-root-gslminimizer-root-egslminimizertype/48322/19 "2022-01-26T01:41:32Z")

</div>

Closed on January 26, 2022, 1:41am UTC

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