GENIE Generator 无法链接到 GSL 库(对“gsl_spline2d_*”的引用未定义)

GENIE Generator 无法链接到 GSL 库(对“gsl_spline2d_*”的引用未定义)

我正在尝试在 Ubuntu 18.04 中安装 GENIE Generator,它依赖于

安装先决条件:

  • ROOT(版本 6.14.00)
  • GNU 科学库 (GSL)
  • 腐霉6
  • LHAPDF5 或 LHAPDF6
  • log4cpp
  • libxml2

我已经安装了 PYTHIA6、LHAPDF6、log4cpp、libxml2、GSL 以及带有 GSL 的 ROOT。我可以使用 g++ 和 root 运行以下测试代码(带有 GSL 函数)。

#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;
}

我使用这个命令来运行这个测试文件。

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

这表明 GSL 已正确安装在系统中。我也在 .bashrc 文件中导出了路径。

# 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

现在,当我运行 GENIE Generator 的编译时,它显示错误。

cd ~/Products
mkdir GENIE
cd GENIE
git clone https://github.com/GENIE-MC/Generator.git
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         http://www.genie-mc.org       **
**  `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 

此后显示以下错误。

.
.
.
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

库文件我们可以在下面的目录中找到我们所期望的文件:

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

由于 gsl-config 显示了库的位置。很明显 libgsl 安装正确(使用源代码手动编译),示例 C++ 程序可以使用相同的函数而不会出现任何错误。但不知何故,GENIE 编译无法使用 gsl 库并显示未定义的函数。

如果有人能提供可能出现问题的线索,这将会很有帮助。

答案1

对于 OP 来说可能已经太晚了,但对于将来遇到这种情况的人来说,我找到了一种解决方法(?)。

目录中 gevgen 的 Makefile 中有一行,GENIE/Generator/src/Apps/用于在编译期间查找必要的库及其依赖项。-L/path/to/ROOT/libs -lgsl由于某种原因,它返回了 ,试图链接到 ROOT libs 目录中的 gsl 库,而不是 GSL 目录中的 gsl 库。也许如果 ROOT 是由脚本构建的lamp,那么就会存在这样的动态库,但就我而言(链接到外部构建的 ROOT),我只能找到一个静态libgsl.a文件。另一方面,libgsl.so处有一个动态文件GENIE/GENIESupport/gsl/lib/libgsl.so,因此我在目录中创建了指向此文件的软链接ROOT/libs,此后构建完成,没有出现其他问题。

答案2

也许您可以指向当前 GSL 安装找到它:

locate libgsl | fgrep .so 

相关内容