GENIE Generator is unable to link to GSL library (undefined reference to `gsl_spline2d_*')

I am trying to install GENIE Generator in Ubuntu 18.04 which depends on

Installing Prerequisites:

  • ROOT(version 6.14.00)
  • GNU Scientific Library (GSL)
  • PYTHIA6
  • LHAPDF5 or LHAPDF6
  • log4cpp
  • libxml2

I have installed PYTHIA6, LHAPDF6, log4cpp, libxml2, GSL as well as ROOT with GSL. I can run following test code (with GSL function) using both g++ as well as root.

#include<iostream>
#include "gsl/gsl_sf_bessel.h"
using namespace std;
int main()
{ double x = 15.0; double y = gsl_sf_bessel_J0 (x); cout<<x<<"\t"<<y<<endl; return 0;
}

I use this command to run this test file.

g++ hello.cc -o hello $(gsl-config --cflags --libs)
./hello

This indicate that GSL is properly installed in system. I have exported path in .bashrc file also.

# For ROOT
#export ROOTSYS=/home/anil/Products/root
export ROOTSYS=/home/anil/Products/root_v6.14.00-build
export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib/:$LD_LIBRARY_PATH
#Pythia 8
export PYTHIA8=/home/anil/Products/pythia8235
export PYTHIA8DATA=$PYTHIA8/share/Pythia8/xmldoc
export PATH=$PYTHIA8/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PYTHIA8/lib
#Pythia 6
export PYTHIA6=/home/anil/Products/pythia6428
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PYTHIA6428/lib
#GSL-2.5
export GSLHOME=/home/anil/Products/gsl25
export GSL_INC=$GSLHOME/include
export GSL_LIB=$GSLHOME/lib
export PATH=$GSLHOME/bin:$PATH
#export LIBRARY_PATH=$LIBRARY_PATH:$GSLHOME/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSLHOME/lib
#CLHEP-2.4.0.4
export CLHEP_BASE_DIR=/home/anil/Products/CLHEP/clhep2404
export PATH=$CLHEP_BASE_DIR/bin:$PATH
export LD_LIBRARY_PATH=$CLHEP_BASE_DIR/lib:$LD_LIBRARY_PATH
#GEANT4
export G4INSTALL=/home/anil/Products/GEANT4/geant4.10.04.p02-install/share/Geant4-10.4.2/geant4make
export G4WORKDIR=/home/anil/G4WORK
source $G4INSTALL/geant4make.sh
source /home/anil/Products/GEANT4/geant4.10.04.p02-install/bin/geant4.sh

Now when I am running the compilation of GENIE Generator and it shows error.

cd ~/Products
mkdir GENIE
cd GENIE
git clone
cd Generator
export GENIE=$(pwd)
./configure --prefix=/home/anil/Products/GENIE/genie --disable-profiler --disable-validation-tools --disable-cernlib --enable-lhapdf6 --enable-flux-drivers --enable-geom-drivers --disable-doxygen --enable-test --enable-mueloss --enable-dylibversion --enable-t2k --enable-fnal --enable-atmo --enable-nucleon-decay --disable-masterclass --disable-debug --with-optimiz-level=O2 --with-pythia6-lib=/home/anil/Products/pythia6428/libPythia6.so --with-lhapdf6-inc=/home/anil/Products/LHAPDF/lhapdf621/include --with-lhapdf6-lib=/home/anil/Products/LHAPDF/lhapdf621/lib --with-libxml2-inc=/home/anil/Products/LIBXML2/libxml2/include/libxml2 --with-libxml2-lib=/home/anil/Products/LIBXML2/libxml2/lib --with-log4cpp-inc=/home/anil/Products/LOG4CPP/log4cpp/include --with-log4cpp-lib=/home/anil/Products/LOG4CPP/log4cpp/lib
********************************************************************************************************
********************************************************************************************************
** **
** .oooooo. oooooooooooo ooooo ooo ooooo oooooooooooo **
** d8P' `Y8b `888' `8 `888b. `8' `888' `888' `8 NEUTRINO MONTE CARLO GENERATOR **
** 888 888 8 `88b. 8 888 888 **
** 888 888oooo8 8 `88b. 8 888 888oooo8 Version 999.999.999 **
** 888 ooooo 888 " 8 `88b.8 888 888 " **
** `88. .88' 888 o 8 `888 888 888 o **
** `Y8bood8P' o888ooooood8 o8o `8 o888o o888ooooood8 **
** **
** (c) 2003-2018 GENIE Collaboration **
** **
********************************************************************************************************
********************************************************************************************************
/home/anil/Products/GENIE/Generator/configure
The $PYTHIA6 env var is defined. I will pick that and set --with-pythia6-lib=/home/anil/Products/pythia6428
Your input configuration options were: --prefix=/home/anil/Products/GENIE/genie --disable-profiler --disable-validation-tools --disable-cernlib --enable-lhapdf6 --enable-flux-drivers --enable-geom-drivers --disable-doxygen --enable-test --enable-mueloss --enable-dylibversion --enable-t2k --enable-fnal --enable-atmo --enable-nucleon-decay --disable-masterclass --disable-debug --with-optimiz-level=O2 --with-pythia6-lib=/home/anil/Products/pythia6428/libPythia6.so --with-lhapdf6-inc=/home/anil/Products/LHAPDF/lhapdf621/include --with-lhapdf6-lib=/home/anil/Products/LHAPDF/lhapdf621/lib --with-libxml2-inc=/home/anil/Products/LIBXML2/libxml2/include/libxml2 --with-libxml2-lib=/home/anil/Products/LIBXML2/libxml2/lib --with-log4cpp-inc=/home/anil/Products/LOG4CPP/log4cpp/include --with-log4cpp-lib=/home/anil/Products/LOG4CPP/log4cpp/lib
The /home/anil/Products/GENIE/Generator/src/make/Make.config file has been succesfully generated!
The following config options were set: GENIE_INSTALLATION_PATH=/home/anil/Products/GENIE/genie GOPT_ENABLE_LHAPDF5=NO GOPT_ENABLE_LHAPDF6=YES GOPT_ENABLE_T2K=YES GOPT_ENABLE_FNAL=YES GOPT_ENABLE_ATMO=YES GOPT_ENABLE_NUCLEON_DECAY=YES GOPT_ENABLE_NNBAR_OSCILLATION=NO GOPT_ENABLE_BOOSTED_DARK_MATTER=NO GOPT_ENABLE_FLUX_DRIVERS=YES GOPT_ENABLE_GEOM_DRIVERS=YES GOPT_ENABLE_MASTERCLASS=NO GOPT_ENABLE_TEST=YES GOPT_ENABLE_PROFILER=NO GOPT_ENABLE_DOXYGEN_DOC=NO GOPT_ENABLE_DYLIBVERSION=YES GOPT_ENABLE_LOW_LEVEL_MESG=NO GOPT_WITH_COMPILER=gcc GOPT_WITH_CXX_DEBUG_FLAG= GOPT_WITH_CXX_OPTIMIZ_FLAG=-O2 GOPT_WITH_PROFILER_LIB= GOPT_WITH_DOXYGEN_PATH= GOPT_WITH_PYTHIA6_LIB=/home/anil/Products/pythia6428 GOPT_WITH_LHAPDF5_LIB= GOPT_WITH_LHAPDF5_INC= GOPT_WITH_LHAPDF6_LIB=/home/anil/Products/LHAPDF/lhapdf621/lib GOPT_WITH_LHAPDF6_INC=/home/anil/Products/LHAPDF/lhapdf621/include GOPT_WITH_LIBXML2_INC=/home/anil/Products/LIBXML2/libxml2/include/libxml2 GOPT_WITH_LIBXML2_LIB=/home/anil/Products/LIBXML2/libxml2/lib GOPT_WITH_LOG4CPP_INC=/home/anil/Products/LOG4CPP/log4cpp/include GOPT_WITH_LOG4CPP_LIB=/home/anil/Products/LOG4CPP/log4cpp/lib
*** To continue building GENIE type: make
make 

After this it shows the following error.

.
.
.
g++ -c -W -Wall -fPIC -Wshadow -pthread -std=c++11 -m64 -I/home/anil/Products/root_v6.14.00-build/include -O2 -I/home/anil/Products/LIBXML2/libxml2/include/libxml2 -I/home/anil/Products/LOG4CPP/log4cpp/include -I/home/anil/Products/root_v6.14.00-build/include -I/home/anil/Products/GENIE/Generator/src/ _ROOT_DICT_TlGeo.cc
[package: Tools/Geometry] Generating shared library ..dictionary=._ROOT_DICT_TlGeo
g++ -shared GeomVolSelectorFiducial.o GeomVolSelectorI.o GeoUtils.o ROOTGeomAnalyzer.o PointGeomAnalyzer.o PathSegmentList.o GeomVolSelectorRockBox.o GeomVolSelectorBasic.o FidShape.o _ROOT_DICT_TlGeo.o -o /home/anil/Products/GENIE/Generator/lib/libGTlGeo-999.999.999.so
[ ! -f libGTlGeo_rdict.pcm ] || cp libGTlGeo_rdict.pcm /home/anil/Products/GENIE/Generator/lib
[ ! -f libGTlGeo.rootmap ] || cp libGTlGeo.rootmap /home/anil/Products/GENIE/Generator/lib
[package: Tools/Geometry] Creating symbolic link to shared library ...
ln -sf libGTlGeo-999.999.999.so /home/anil/Products/GENIE/Generator/lib/libGTlGeo.so
make[1]: Leaving directory '/home/anil/Products/GENIE/Generator/src/Tools/Geometry'
** Masterclass was not enabled. Skipping...
** Building GENIE applications...
cd /home/anil/Products/GENIE/Generator/src/Apps && \
make all && \
cd /home/anil/Products/GENIE/Generator
make[1]: Entering directory '/home/anil/Products/GENIE/Generator/src/Apps'
g++ -W -Wall -fPIC -Wshadow -pthread -std=c++11 -m64 -I/home/anil/Products/root_v6.14.00-build/include -O2 -MMD -MP -c -I/home/anil/Products/LIBXML2/libxml2/include/libxml2 -I/home/anil/Products/LOG4CPP/log4cpp/include -I/home/anil/Products/root_v6.14.00-build/include -I/home/anil/Products/LHAPDF/lhapdf621/include -I/home/anil/Products/gsl25/include -I/home/anil/Products/GENIE/Generator/src/ gEvGen.cxx -o gEvGen.o
** Building gevgen
g++ -g -Wl,--no-as-needed -Wl,--no-undefined gEvGen.o -L/home/anil/Products/root_v6.14.00-build/lib -lGui -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTDataFrame -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -pthread -lm -ldl -rdynamic -lMinuit -lGeom -lEG -lEGPythia6 -lGenVector -L/home/anil/Products/pythia6428 -lPythia6 -L/home/anil/Products/LHAPDF/lhapdf621/lib -lLHAPDF -L/home/anil/Products/LIBXML2/libxml2/lib -lxml2 -L/home/anil/Products/LOG4CPP/log4cpp/lib -llog4cpp -L/home/anil/Products/gsl25/lib -lgsl -lgslcblas -lm -lnsl -L/home/anil/Products/GENIE/Generator/lib -lGFwMsg -lGFwReg -lGFwAlg -lGFwInt -lGFwGHEP -lGFwNum -lGFwUtl -lGFwParDat -lGFwEG -lGFwNtp -lGPhXSIg -lGPhPDF -lGPhNuclSt -lGPhCmn -lGPhDcy -lGPhHadTransp -lGPhHadnz -lGPhDeEx -lGPhAMNGXS -lGPhAMNGEG -lGPhChmXS -lGPhCohXS -lGPhCohEG -lGPhDISXS -lGPhDISEG -lGPhDfrcXS -lGPhDfrcEG -lGPhGlwResXS -lGPhGlwResEG -lGPhIBDXS -lGPhIBDEG -lGPhMNucXS -lGPhMNucEG -lGPhMEL -lGPhNuElXS -lGPhNuElEG -lGPhQELXS -lGPhQELEG -lGPhResXS -lGPhResEG -lGPhStrXS -lGPhStrEG -lGPhNDcy -lGTlGeo -lGTlFlx -o /home/anil/Products/GENIE/Generator/bin/gevgen
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_spline2d_eval_deriv_y'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_spline2d_init'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_spline2d_eval_deriv_yy'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_interp_accel_alloc'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_spline2d_eval_deriv_x'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_interp2d_bilinear'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_spline2d_eval'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_spline2d_alloc'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_spline2d_eval_deriv_xy'
/home/anil/Products/GENIE/Generator/lib/libGFwNum.so: undefined reference to `gsl_spline2d_eval_deriv_xx'
collect2: error: ld returned 1 exit status
Makefile:90: recipe for target '/home/anil/Products/GENIE/Generator/bin/gevgen' failed
make[1]: *** [/home/anil/Products/GENIE/Generator/bin/gevgen] Error 1
make[1]: Leaving directory '/home/anil/Products/GENIE/Generator/src/Apps'
Makefile:243: recipe for target 'apps' failed
make: *** [apps] Error 2

The libgsl.a file can be found in the following directories which is what we expect:

anil@anilpc:~/Products/GENIE/Generator$ locate libgsl.a
/home/anil/Products/gsl-2.5/.libs/libgsl.a
/home/anil/Products/gsl25/lib/libgsl.a
/home/anil/Products/root_v6.14.00-build/GSL-prefix/src/GSL-build/.libs/libgsl.a
/home/anil/Products/root_v6.14.00-build/lib/libgsl.a
anil@anilpc:~$ gsl-config --cflags --libs
-I/home/anil/Products/gsl25/include
-L/home/anil/Products/gsl25/lib -lgsl -lgslcblas -lm

Since the gsl-config shows location of library. It is clear that libgsl in installed properly (compiled mannually using source code) and the example C++ program can use the same functions without any error. But somehow the GENIE compilation is unable to use gsl library and show undefined functions.

It will be helpful if someone can give a clue what could be possibly wrong.

1

2 Answers

It's probably too late for OP, but for anyone coming across this in the future, I found a workaround(?) for this.

There is a line in the Makefile for gevgen, in the GENIE/Generator/src/Apps/ directory, which looks up the necessary libraries and their dependencies during compilation. It was returning -L/path/to/ROOT/libs -lgsl, for some reason trying to link against the gsl library in the ROOT libs directory, rather than the GSL directory. Perhaps if ROOT is built by the lamp script, such a dynamic library exists, but in my case (linking against an externally built ROOT) I was only able to find a static libgsl.a file. On the other hand a dynamic libgsl.so file was present at GENIE/GENIESupport/gsl/lib/libgsl.so, so i made a softlink to this file in the ROOT/libs directory, and thereafter the build completed without further problems.

1

Perhaps you can point to the current GSL install find it:

locate libgsl | fgrep .so 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like