# Legendre polynomials missing, not linking to GSL (Mathmore already installed)

**URL:** <https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879>\
**Category:** Newbie\
**Created:** [June 27, 2019, 2:16pm UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879 "2019-06-27T14:16:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbrummer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jbrummer](https://root-forum.cern.ch/u/jbrummer)\
**Post date:** [June 27, 2019, 2:16pm UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/1 "2019-06-27T14:16:45Z")

</div>

Hello everyone,

I have a problem in accessing the Legendre polynomials but it is not as simple as just enabling Mathmore when configuring ROOT. Firstly, I run ROOT v5-34-00-patches installed on Ubuntu 18.04. The configure script that I used now was:  
./configure --enable-mathmore --enable-minuit2 --enable-gsl-shared --disable-fitsio

and then I ran make, of course, and everything seems to be working well. The problem that I’m having is that, while I can compile and run the Legendre scripts in the root tutorials in “~/root/v5-34-00-patches/tutorials/math/”, I am not able to use “ROOT::Math::legendre” directly (for lack of a better word). Please see the attachment which has a snippet of my code.

The scripts in the tutorial folder work perfectly as they use a TF1 when declaring the Legendre function:  
L[nu]= new TF1(“L\_0”, “ROOT::Math::legendre([0],x)”, -1, 1);

However, for my research I can’t just use the TF1 in my fit function shown in the attachment.  
The code fails when I run it because ROOT does not seem to be linking to the Legendre polynomials in the gsl library.

When in ROOT and using the tab button to autocomplete, I get the following:

root [23] ROOT::Math::l  
lgamma  
landau\_pdf  
lognormal\_pdf  
landau\_cdf  
landau\_cdf\_c  
lognormal\_cdf\_c  
lognormal\_cdf  
landau\_xm1  
landau\_xm2  
lognormal\_quantile\_c  
lognormal\_quantile  
landau\_quantile  
landau\_quantile\_c  
root [23] ROOT::Math::l

So you see that some of the functions are present but others are not (such as the Legendre and associated Legendre polynomials).

To get around this problem I had to do “#include \</usr/include/gsl/gsl\_sf\_legendre.h\>” at the start of my script and use the function directly as:  
result += pars[L] \* gsl\_sf\_legendre\_Pl(2\*L,x[0] \* TMath::Pi()/180.);

This worked. So all of the files are present where they should be but ROOT is just not finding some of them which is odd. Is there anyone that can advise on this matter?

I would like to find a solution other than just installing the latest ROOT v6  
as I know that the scripts that I have written for my PhD (final year) may suddenly encounter errors that ROOT v5 does not show.

[FitFunction.cpp](https://root-forum.cern.ch/uploads/default/original/3X/0/e/0ea4e95702e74943075919f09f2963c633329417.cpp) (197 Bytes)

---

<div class="post-metadata">

**Author:** ![Pnine](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/cc9497/32.png) [@Pnine](https://root-forum.cern.ch/u/Pnine)\
**Post date:** [June 27, 2019, 2:25pm UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/2 "2019-06-27T14:25:03Z")

</div>

Hi,

can you try with ROOT 6.18?

Best,  
P

---

<div class="post-metadata">

**Author:** ![jbrummer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jbrummer](https://root-forum.cern.ch/u/jbrummer)\
**Post date:** [June 27, 2019, 2:41pm UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/3 "2019-06-27T14:41:43Z")

</div>

That’s one of the issues I have. Firstly, I have never installed ROOT6 so I’m not sure how and secondly I would prefer to have a solution so that I can still use ROOT5 so that I don’t have to review many of my scripts to comply with ROOT6.

---

<div class="post-metadata">

**Author:** ![jbrummer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jbrummer](https://root-forum.cern.ch/u/jbrummer)\
**Post date:** [June 27, 2019, 2:43pm UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/4 "2019-06-27T14:43:45Z")

</div>

I’m going to try and build ROOT6 in another directory to check anyway.

---

<div class="post-metadata">

**Author:** ![Pnine](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/cc9497/32.png) [@Pnine](https://root-forum.cern.ch/u/Pnine)\
**Post date:** [June 27, 2019, 2:55pm UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/5 "2019-06-27T14:55:57Z")

</div>

Hello,

just saying because I think ROOT5 development stopped a while ago and many things are fixed in ROOT6 and/or dramatically improved…

---

<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:** [June 27, 2019, 3:45pm UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/6 "2019-06-27T15:45:41Z")

</div>

If you run your macros through the standard “root” (or “root.exe”) executable, try to create a “rootlogon.C” file:

```cpp
void rootlogon(void) { // rootlogon.C ...
  // std::cout << "... rootlogon.C ..." << std::endl;
  if (gROOT->GetVersionCode() < 393216) { // 393216 = ROOT_VERSION(6,00,00)
    gSystem->Load("libMathMore");
  }
} // ... rootlogon.C

```

---

<div class="post-metadata">

**Author:** ![jbrummer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jbrummer](https://root-forum.cern.ch/u/jbrummer)\
**Post date:** [June 28, 2019, 8:58am UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/7 "2019-06-28T08:58:50Z")

</div>

Hi there Wile\_E

Once again, you are dead right. I created the file and just edited gedit $ROOTSYS/etc/system.rootrc . It works well now. Thank you once more for the help.

---

<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:** [June 28, 2019, 9:00am UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/8 "2019-06-28T09:00:37Z")

</div>

You do not need to modify “${ROOTSYS}/etc/system.rootrc” at all.

---

<div class="post-metadata">

**Author:** ![jbrummer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@jbrummer](https://root-forum.cern.ch/u/jbrummer)\
**Post date:** [June 28, 2019, 9:11am UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/9 "2019-06-28T09:11:57Z")

</div>

Let me ask then where should I keep rootlogon.C? I know it is usually in the home folder as is specified in $ROOTSYS/etc/system.rootrc but what if my install is in home/Programs/v5-34-00-patches?

I uncommented the cout to make sure it’s loaded and when I put it in home, it’s only loaded when I run the command root from home. I got it to work globally by putting it where I specified earlier. What should I then rather be doing if it doesn’t work globally if placed in home?

---

<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:** [June 28, 2019, 9:31am UTC](https://root-forum.cern.ch/t/legendre-polynomials-missing-not-linking-to-gsl-mathmore-already-installed/34879/10 "2019-06-28T09:31:38Z")

</div>

You can have a local “rootlogon.C” in your “current working subdirectory” and / or a global “rootlogon.C” in your “${HOME}” subdirectory.
