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.