Problem compiling with CLHEP flag

Dear experts,

I’m trying to compile my code with Geant4 provided in lxplus by LCG_100:

/cvmfs/sft.cern.ch/lcg/releases/Geant4/10.07.p01-daa34/x86_64-centos7-gcc8-opt/

Using the usual cmake3 build shows no errors, however when trying to compile it the error thrown says -lCHLEP-2.4.4.0 has not been found:

/cvmfs/sft.cern.ch/lcg/releases/binutils/2.30-e5b21/x86_64-centos7/bin/ld: cannot find -lCLHEP-2.4.4.0
collect2: error: ld returned 1 exit status

Indeed, the Geant4 build in lxplus has an external CLHEP libs linked to it:

-L/cvmfs/sft.cern.ch/lcg/releases/Geant4/10.07.p01-daa34/x86_64-centos7-gcc8-opt/bin/../lib64
-lG4OpenGL -lG4gl2ps -lG4Tree -lG4FR -lG4GMocren -lG4visHepRep -lG4RayTracer -lG4VRML 
-lG4vis_management -lG4modeling -lG3toG4 -lG4interfaces -lG4persistency 
-lG4analysis -lG4error_propagation -lG4readout -lG4physicslists -lG4run -lG4event 
-lG4tracking -lG4parmodels -lG4processes -lG4digits_hits -lG4track -lG4particles 
-lG4geometry -lG4materials -lG4graphics_reps -lG4intercoms -lG4global 
-L/cvmfs/sft.cern.ch/lcg/releases/clhep/2.4.4.0-b903d/x86_64-centos7-gcc8-opt/lib 
-lCLHEP-2.4.4.0 -lG4expat -lG4zlib

so, I have modified the cmake Module FindGeant4.cmake from G4clhep to CLHEP-2.4.4.0, but it doesn’t work. Using G4clhep works fine with my local Geant4 build where G4clhep is built-in, however I have to link my code against the LCG CLHEP lib.

Is there a proper way to set the cmake Module to link this external lib?

Cheers, Gustavo

Hi, are you setting up the LCG stack the usual way? The external CLHEP should be setup together with Geant4 in that case. Can you please post more context of your error messages, like the output from CMake at configuration time and maybe how your code is using Geant4 in its CMakeLists.txt?

Hi Guilherme,

Thanks for your quick reply. Yes, I’m setting the LCG stack as recommended by SFT:

source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_100 x86_64-centos7-gcc8-opt

I’m compiling a c++ PhysicsList to be used later with my G4 code written in python3 as shared lib. The cmake output shows everything OK:

-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/gcc
-- Check for working C compiler: /cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/gcc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/g++
-- Check for working CXX compiler: /cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/g++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Geant4: /cvmfs/sft.cern.ch/lcg/releases/Geant4/10.07.p01-daa34/x86_64-centos7-gcc8-opt/bin/.. (10.7.1)
-- Found PythonInterp: /cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc8-opt/bin/python (found version "3.8.6") 
-- Found PythonLibs: /cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc8-opt/lib/libpython3.8.so (found version "3.8.6") 
-- Found Boost: /cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc8-opt/lib/cmake/Boost-1.75.0/BoostConfig.cmake (found version "1.75.0")  
-- Found XercesC: /cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc8-opt/lib/libxerces-c.so  
-- Found ROOT 6.24/00 in /cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.24.00-a725e/x86_64-centos7-gcc8-opt
-- Configuring done
-- Generating done
-- Build files have been written to: /afs/cern.ch/user/<path>/Physics/build

The CMakeList.txt is targeting the needed libs to compile the PhysicsList:

...
include_directories(
  ${PYTHON_INCLUDE_PATH}
  ${Boost_INCLUDE_DIRS}
  ${GEANT4_INCLUDE_DIR}
)

link_directories (${GEANT4_LIBRARY_DIR} ${Boost_LIBRARY_DIRS})

# library
set(_TARGET CosmicG4Physics)
add_library(
  ${_TARGET} SHARED
  CosmicG4Physics_Boson.cc
  CosmicG4Physics_Lepton.cc
  CosmicG4PhysicsList.cc
  CosmicG4Physics_wrapper.cc
  GammaPhysics.cc
)
...

And finally the cmake Module should find the proper libs:

set(GEANT4_INCLUDE_DIR ${GEANT4_PREFIX}/include/Geant4)
set(GEANT4_LIBRARY_DIR ${GEANT4_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(GEANT4_LIBRARIES  G4interfaces G4persistency G4analysis
                      G4error_propagation G4readout G4physicslists
                      G4run G4event G4tracking G4parmodels G4processes
                      G4digits_hits G4track G4particles G4geometry
                      G4materials G4graphics_reps G4intercoms
                      G4global CLHEP-2.4.4.0)

set(GEANT4_LIBRARIES_WITH_VIS
                      G4OpenGL G4gl2ps G4Tree G4FR G4GMocren G4visHepRep
                      G4RayTracer G4VRML G4vis_management G4modeling
                      G4interfaces G4persistency G4analysis
                      G4error_propagation G4readout G4physicslists
                      G4run G4event G4tracking G4parmodels G4processes
                      G4digits_hits G4track G4particles G4geometry
                      G4materials G4graphics_reps G4intercoms
                      G4global CLHEP-2.4.4.0)

Unfortunately I don’t see why CLHEP-2.4.4.0 has not been seen/found in this build.

Note how ROOT and Geant4 come from releases/ while other things come from views/. Maybe there’s a problem with how you are setting up ROOT and Geant4 along with the LCG stack. Look in your bashrc, you may find a setup for ROOT/Geant4 there overriding the LCG setup. When I source just LCG, Geant4 also comes from the views/ directory:

lxplus ~ $ source /cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc8-opt/setup.sh 
lxplus ~ $ which geant4-config
/cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc8-opt/bin/geant4-config

Hi Guilherme,

Indeed, I didn’t noticed that, however I have no other settings in my .bashrc or .bash_profile, which triggers me to check the setupView.sh. Although the script links Geant4 from the view’s path:

$thisdir/bin/geant4-config

I got a different result if I query the prefix with that path:

> /cvmfs/sft.cern.ch/lcg/views/LCG_100/x86_64-centos7-gcc8-opt/bin/geant4-config --prefix
/cvmfs/sft.cern.ch/lcg/releases/Geant4/10.07.p01-daa34/x86_64-centos7-gcc8-opt/bin/..

Anyway, the script for that LCG stack seems to be buggy; I’ll contact SFT to fix that.

Cheers, Gustavo

To summarize: a ticket has been opened in SFT SPI-1957, which points out small changes needed in CMakeLists.txt to finally go through the compilation steps. It works for general use, however the LCG build pf Geant4 doesn’t include python support.

Cheers, Gustavo

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.