Error when making geant4

Hello everyone.

I’m trying to install the geant4.10.06 version in my CentOS7 system provided by the CERN NICE System. I’ve followed the instructions in the installation guide of Geant4 webpage.

For the cmake step, I’ve run:

cmake3 -DCMAKE_INSTALL_PREFIX=/usr/local -DGEANT4_BUILD_MULTITHREADED=ON -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_SYSTEM_CLHEP=ON ~/Geant4/geant4.10.06/

and returned no error.

Then, for the make step, I’ve run:

make -j8

At 10% it gave me the following error:

[ 10%] Building CXX object source/geometry/CMakeFiles/G4geometry.dir/magneticfield/src/G4VIntegrationDriver.cc.o
/afs/cern.ch/user/a/akanella/Geant4/geant4.10.06/source/geometry/magneticfield/src/G4FieldManagerStore.cc: In static member function ‘static void G4FieldManagerStore::DeRegister(G4FieldManager*)’:
/afs/cern.ch/user/a/akanella/Geant4/geant4.10.06/source/geometry/magneticfield/src/G4FieldManagerStore.cc:119:31: error: no matching function for call to ‘G4FieldManagerStore::erase(__gnu_cxx::__normal_iterator<G4FieldManager* const*, std::vector<G4FieldManager*> >&)’
GetInstance()->erase(i);
^
/afs/cern.ch/user/a/akanella/Geant4/geant4.10.06/source/geometry/magneticfield/src/G4FieldManagerStore.cc:119:31: note: candidates are:
In file included from /usr/include/c++/4.8.2/vector:69:0,
from /afs/cern.ch/user/a/akanella/Geant4/geant4.10.06/source/geometry/magneticfield/include/G4FieldManagerStore.hh:45,
from /afs/cern.ch/user/a/akanella/Geant4/geant4.10.06/source/geometry/magneticfield/src/G4FieldManagerStore.cc:32:
/usr/include/c++/4.8.2/bits/vector.tcc:134:5: note: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::iterator) [with _Tp = G4FieldManager*; _Alloc = std::allocator<G4FieldManager*>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<G4FieldManager**, std::vector<G4FieldManager*> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = G4FieldManager**]
vector<_Tp, _Alloc>::
^
/usr/include/c++/4.8.2/bits/vector.tcc:134:5: note: no known conversion for argument 1 from ‘__gnu_cxx::__normal_iterator<G4FieldManager* const*, std::vector<G4FieldManager*> >’ to ‘std::vector<G4FieldManager*>::iterator {aka __gnu_cxx::__normal_iterator<G4FieldManager**, std::vector<G4FieldManager*> >}’
/usr/include/c++/4.8.2/bits/vector.tcc:146:5: note: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::iterator, std::vector<_Tp, _Alloc>::iterator) [with _Tp = G4FieldManager*; _Alloc = std::allocator<G4FieldManager*>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<G4FieldManager**, std::vector<G4FieldManager*> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = G4FieldManager**]
vector<_Tp, _Alloc>::
^
/usr/include/c++/4.8.2/bits/vector.tcc:146:5: note: candidate expects 2 arguments, 1 provided
make[2]: *** [source/geometry/CMakeFiles/G4geometry.dir/magneticfield/src/G4FieldManagerStore.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [source/geometry/CMakeFiles/G4geometry.dir/all] Error 2
make: *** [all] Error 2

I don’t see where is the problem with the G4FieldManagerStore.cc file and why the GetInstance()->erase(i); line raises an error.

Any ideas how to resolve this? Let me know if you need any extra info. :grinning:

You must use a more recent gcc compiler to build Geant4 10.6.
The minimum required is gcc-4.9.3 and you’re using gcc-4.8.2…

1 Like

Hello Akanella,

To complete the answer of gcosmo, you have two solutions:

Thank you all very much. I’ve updated gcc to a more recent version and the problem is solved.

I have a similar problem. I am running with gcc/6.2.0 but get similar problem:

[ 14%] Linking CXX shared library …/…/BuildProducts/lib64/libG4analysis.so
/home/rickf/Geant4/geant4.10.06.p02/source/geometry/magneticfield/src/G4FieldManagerStore.cc: In static member function ‘static void G4FieldManagerStore::DeRegister(G4FieldManager*)’:
/home/rickf/Geant4/geant4.10.06.p02/source/geometry/magneticfield/src/G4FieldManagerStore.cc:119:31: error: no matching function for call to ‘G4FieldManagerStore::erase(__gnu_cxx::__normal_iterator<G4FieldManager* const*, std::vector<G4FieldManager*> >&)’
GetInstance()->erase(i);
^
/home/rickf/Geant4/geant4.10.06.p02/source/geometry/magneticfield/src/G4FieldManagerStore.cc:119:31: note: candidates are:
In file included from /usr/include/c++/4.8.2/vector:69:0,
from /home/rickf/Geant4/geant4.10.06.p02/source/geometry/magneticfield/include/G4FieldManagerStore.hh:45,
from /home/rickf/Geant4/geant4.10.06.p02/source/geometry/magneticfield/src/G4FieldManagerStore.cc:32:
/usr/include/c++/4.8.2/bits/vector.tcc:134:5: note: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::iterator) [with _Tp = G4FieldManager*; _Alloc = std::allocator<G4FieldManager*>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<G4FieldManager**, std::vector<G4FieldManager*> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = G4FieldManager**]
vector<_Tp, _Alloc>::
^
/usr/include/c++/4.8.2/bits/vector.tcc:134:5: note: no known conversion for argument 1 from ‘__gnu_cxx::__normal_iterator<G4FieldManager* const*, std::vector<G4FieldManager*> >’ to ‘std::vector<G4FieldManager*>::iterator {aka __gnu_cxx::__normal_iterator<G4FieldManager**, std::vector<G4FieldManager*> >}’
/usr/include/c++/4.8.2/bits/vector.tcc:146:5: note: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::iterator, std::vector<_Tp, _Alloc>::iterator) [with _Tp = G4FieldManager*; _Alloc = std::allocator<G4FieldManager*>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<G4FieldManager**, std::vector<G4FieldManager*> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = G4FieldManager**]
vector<_Tp, _Alloc>::
^
/usr/include/c++/4.8.2/bits/vector.tcc:146:5: note: candidate expects 2 arguments, 1 provided
make[2]: *** [source/geometry/CMakeFiles/G4geometry.dir/magneticfield/src/G4FieldManagerStore.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [source/geometry/CMakeFiles/G4geometry.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
[ 14%] Built target G4analysis
make: *** [all] Error 2

Looks like the compiler/environment is configured incorrectly, as it’s picking up headers from GCC 4.8.2.

Yes, I suspect cmake is doing this. Is there a way to tell cmake to select another path? The environment I am running in is a large cluster and cannot change the fact there is a /usr/include/c++/4.8.2, but I do know the path for the more up to date include files.

Did you clear all of the originally created build files and cached values?

Looks like cmake can’t alter the compiler if you have already run the configuration step once.

Yes, I deleted the entire geant4 build directory, before rerunning cmake.

Weird, does cmake definitely think it should be using gcc 6.2.0? i.e. what does the config output say? I’m on debian 10 and get this

-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version "2.2.6") 
.
.
.
lots of other output

Other than the config output as @php1ic suggests, maybe also check the environment settings in the session. It’s just possible something there might be interfering like CPATH.

After building and installing successfully, while running exampleB1, I got this error…Scanning dependencies of target exampleB1 [ 12%] Building CXX object CMakeFiles/exampleB1.dir/src/B1ActionInitialization.cc.o [ 25%] Building CXX object CMakeFiles/exampleB1.dir/exampleB1.cc.o [ 37%] Building CXX object CMakeFiles/exampleB1.dir/src/B1DetectorConstruction.cc.o [ 50%] Building CXX object CMakeFiles/exampleB1.dir/src/B1EventAction.cc.o [ 62%] Building CXX object CMakeFiles/exampleB1.dir/src/B1PrimaryGeneratorAction.cc.o [ 75%] Building CXX object CMakeFiles/exampleB1.dir/src/B1RunAction.cc.o [ 87%] Building CXX object CMakeFiles/exampleB1.dir/src/B1SteppingAction.cc.o [100%] Linking CXX executable exampleB1 /usr/bin/ld: /home/inmp/Geant4/Build/geant4.10.06-install/lib/libG4physicslists.so: undefined reference to G4VEmModel::CorrectionsAlongStep(G4MaterialCutsCouple const*, G4DynamicParticle const*, double&, double&, double)’
/usr/bin/ld: /home/inmp/Geant4/Build/geant4.10.06-install/lib/libG4processes.so: undefined reference to G4Absorber::FindAbsorbers(G4KineticTrack&, G4KineticTrackVector&)' /usr/bin/ld: /home/inmp/Geant4/Build/geant4.10.06-install/lib/libG4processes.so: undefined reference to G4VEmProcess::GetMeanFreePath(G4Track const&, double, G4ForceCondition*)’
/usr/bin/ld: /home/inmp/Geant4/Build/geant4.10.06-install/lib/libG4processes.so: undefined reference to G4VEnergyLossProcess::AlongStepGetPhysicalInteractionLength(G4Track const&, double, double, double&, G4GPILSelection*)' /usr/bin/ld: /home/inmp/Geant4/Build/geant4.10.06-install/lib/libG4physicslists.so: undefined reference to G4LossTableManager::EmSaturation()’
/usr/bin/ld: /home/inmp/Geant4/Build/geant4.10.06-install/lib/libG4physicslists.so: undefined reference to G4VEmProcess::~G4VEmProcess()' /usr/bin/ld: /home/inmp/Geant4/Build/geant4.10.06-install/lib/libG4physicslists.so: undefined reference to G4Cerenkov::G4Cerenkov(G4String const&, G4ProcessType)’

/usr/bin/ld: /home/inmp/Geant4/Build/geant4.10.06-install/lib/libG4processes.so: undefined reference to `G4EMDissociationSpectrum::G4EMDissociationSpectrum()’
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/exampleB1.dir/build.make:220: exampleB1] Error 1
make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/exampleB1.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

`
What should I do? Please help

Did you fixed that? I am with similar error.