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

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
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 (197 Bytes)


can you try with ROOT 6.18?


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.

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


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

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

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

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.

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

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?

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