Linking Against Custom GSL

Hi, I’m trying to compile a fixed-location ROOT, linking against a modified version of GSL also living in a specific directory. I’ve got the ROOT source using git, I’ve checked out v5.34.18.

The modifications to GSL add an interpolation type, so I’ve also modified the ROOT source in Math/InterpolationTypes.h and GSLInterpolator.cxx to add references to my new interpolation type. Here is the total diff for the git checkout:

diff --git a/math/mathmore/inc/Math/InterpolationTypes.h b/math/mathmore/inc/Math/InterpolationTypes.h
index a633504..ee20f0f 100644
--- a/math/mathmore/inc/Math/InterpolationTypes.h
+++ b/math/mathmore/inc/Math/InterpolationTypes.h
@@ -50,6 +50,7 @@ namespace Math {
        <li>CSPLINE_PERIODIC cubic spline with periodic boundary conditions;
        <li>AKIMA, Akima spline with natural boundary conditions ( requires a minimum of 5 points);
        <li>AKIMA_PERIODIC, Akima spline with periodic boundaries ( requires a minimum of 5 points); 
+       <li>STEFFEN, Steffen monotonic interpolator ( requires a minimum of 3 points); 
        </ul>
 
 
@@ -62,7 +63,8 @@ namespace Math {
                 kCSPLINE, 
                 kCSPLINE_PERIODIC,  
                 kAKIMA, 
-                kAKIMA_PERIODIC
+                kAKIMA_PERIODIC,
+                KSTEFFEN
     };
   }
 
diff --git a/math/mathmore/src/GSLInterpolator.cxx b/math/mathmore/src/GSLInterpolator.cxx
index 1f5c3a1..9620bd2 100644
--- a/math/mathmore/src/GSLInterpolator.cxx
+++ b/math/mathmore/src/GSLInterpolator.cxx
@@ -63,9 +63,12 @@ GSLInterpolator::GSLInterpolator (unsigned int size, Interpolation::Type type) :
       case ROOT::Math::Interpolation::kAKIMA            :
          fInterpType = gsl_interp_akima; 
          break ;
-      case ROOT::Math::Interpolation::kAKIMA_PERIODIC   :
-         fInterpType = gsl_interp_akima_periodic; 
-         break ;
+   case ROOT::Math::Interpolation::kAKIMA_PERIODIC   :
+       fInterpType = gsl_interp_akima_periodic; 
+       break ;
+   case ROOT::Math::Interpolation::kSTEFFEN  :
+     fInterpType = gsl_interp_steffen;
+     break;
       default :
          // cspline
          fInterpType = gsl_interp_cspline;  

My ./configure command is as follows:

./configure --prefix=/Users/jfcaron/Software/custom_root/compiled --etcdir=/Users/jfcaron/Software/custom_root/compiled/etc --with-gsl-incdir=/Users/jfcaron/Projects/GSL/compiled/include --with-gsl-libdir=/Users/jfcaron/Projects/GSL/compiled/lib --with-f77=/opt/local/bin/gfortran-mp-4.8 make -j8 make install
the official log is attached.

I can compile ROOT without errors (just warnings). I can run ROOT itself and do basic tests in CINT. Unfortunately when I try to use my GSL modifications, my added interpolation type is not found:

jfcaron@dhcp-128-189-72-21:~/Software/custom_root/compiled$ ./bin/root
ROOT 5.34/18 (v5-34-18@v5-34-18, Mar 14 2014, 16:29:50 on macosx64)
*  ROOT v5.34/18  *

root [0] #include "Math/Interpolator.h"
root [1] ROOT::Math::Interpolation::

Type
kLINEAR
kPOLYNOMIAL
kCSPLINE
kCSPLINE_PERIODIC
kAKIMA
kAKIMA_PERIODIC
root [1] ROOT::Math::Interpolation::kSTEFFEN
Error: Symbol kSTEFFEN is not defined in current scope  (tmpfile):1:
*** Interpreter error recovered ***

The same problem occurs when I try to compile a macro that would use my new interpolation type kSTEFFEN. I can confirm that the root binary that I am using for these tests is the one that I compiled myself, but I’m not 100% sure which file is found when I #include “Math/Interpolator.h”. I do have a standard ROOT 5.34.18 installed from MacPorts at /opt/local, so maybe it’s including the header from that installation?

I would appreciate any help in figuring out the problem.

By the way, I am running root directly with ./bin/root. If I do “source bin/thisroot.sh”, then try to run root, the splash screen says it’s ROOT 5.99 and immediately seg faults. The same thing happens if I run ./bin/root after doing “source bin/thisroot.sh”. Is thisroot.sh broken?

Jean-François
config.log.txt (183 KB)

Hi,

I see two separate issues in your post. Unfortunately I cannot reproduce any of the two.

  1. The absence of your change in CINT:
Root5/root ((v5-34-18))$ git diff
diff --git a/math/mathmore/inc/Math/InterpolationTypes.h b/math/mathmore/inc/Math/InterpolationTypes.h
index a633504..298ae77 100644
--- a/math/mathmore/inc/Math/InterpolationTypes.h
+++ b/math/mathmore/inc/Math/InterpolationTypes.h
@@ -61,6 +61,7 @@ namespace Math {
                 kPOLYNOMIAL, 
                 kCSPLINE, 
                 kCSPLINE_PERIODIC,  
+                kTEST,
                 kAKIMA, 
                 kAKIMA_PERIODIC
     };
diff --git a/math/mathmore/src/GSLInterpolator.cxx b/math/mathmore/src/GSLInterpolator.cxx
index 1f5c3a1..2f4933a 100644
--- a/math/mathmore/src/GSLInterpolator.cxx
+++ b/math/mathmore/src/GSLInterpolator.cxx
@@ -60,6 +60,9 @@ GSLInterpolator::GSLInterpolator (unsigned int size, Interpolation::Type type) :
       case ROOT::Math::Interpolation::kCSPLINE_PERIODIC :
          fInterpType = gsl_interp_cspline_periodic  ; 
          break ;
+      case ROOT::Math::Interpolation::kTEST            :
+         fInterpType = gsl_interp_akima; 
+         break ;
       case ROOT::Math::Interpolation::kAKIMA            :
          fInterpType = gsl_interp_akima; 
          break ;
Root5/root ((v5-34-18))$ root -b
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   5.34/18     14 March 2014   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

ROOT 5.34/18 (v5-34-18@v5-34-18, Mar 30 2014, 09:43:15 on linuxx8664gcc)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] #include "Math/Interpolator.h"
root [1] ROOT::Math::Interpolation::

Type
kLINEAR
kPOLYNOMIAL
kCSPLINE
kCSPLINE_PERIODIC
kTEST
kAKIMA
kAKIMA_PERIODIC
  1. The wrong splashscreen and the crash:
    Did you check that your git repo is in the right state? You can do that with the command “git log” and it should output:
commit 37e98489b46e48f2dfacc43251f83d5b8ac1c55e
Author: Fons Rademakers <Fons.Rademakers@cern.ch>
Date:   Fri Mar 14 16:21:52 2014 +0100

    make version v5-34-18.
[....]

Hi, regarding the two issues:

  1. I used “git grep -i ‘akima’” and “git grep -i ‘interpolation’” in the root directory to find any references to specific interpolation types. The only places I found were those two files shown in my diff, nothing came up CINT-wise. Indeed I was worried about CINT itself not picking up the changes as there are some weird things hardcoded into CINT, but that’s why I tried a compiled macro (i.e. run with foo.C++), but that didn’t work either.

  2. I found that the output of “git log” was not as you said I should expect. I think I had messed up the instructions, as my bash history shows that I did “git checkout -b v5-34-18” instead of “git checkout -b v5-34-18 v5-34-18”. I redid the checkout and recompiled everything, now the output of “git log” is as you say I should expect. It is the commit by Fons Rademakers on March 14 for the particular branch. This has fixed the 5.99 seg fault issue after sourcing thisroot.sh

Thanks for helping me resolve at least one of my problems. The issue of using my custom GSL is still outstanding unfortunately.

Jean-François

Hi Jean-François,

a good start to tackle the remaining issue could be, since you mention potential misconfiguration issues, to unsinstall the MacPorts version of ROOT and work with a fresh build (w/o any modification at first and adding your patch in a second moment).

Danilo

That finally worked. After uninstalling the MacPorts-provided ROOT, I recompiled my custom version and it started working (though I had to force-recompile some macros with ++). My modifications with kSTEFFEN work as expected. When GSL ships a new version with my interpolation code, I will submit a ticket to include my modifications to those two ROOT files to enable it within ROOT::Math::Interpolation.

Jean-François