Installing geant4 without root privilege - andreagp/Geant4-tutorial GitHub Wiki
Installing Geant4 10.06.p02
I was installing Geant4 10.06.p02 (I had previously version 10.04) and had an error during complication because the gcc version was an old version. The error was:
[ 10%] Building CXX object source/geometry/CMakeFiles/G4geometry.dir/magneticfield/src/G4VIntegrationDriver.cc.o
/home/local/Geant4/geant4.10.06/source/geometry/magneticfield/src/G4FieldManagerStore.cc: In static member function ‘static void G4FieldManagerStore::DeRegister(G4FieldManager*)’:
/home/local/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);
I had version gcc 9.2 but needed to change to 9.3 without root privileges. For that, you just need to install it in your account and change the library paths. Here is an example done at my /home/andreagutierre:
mkdir local
cd local
wget https://ftp.gnu.org/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz
tar zxvf gcc-9.3.0.tar.gz
mkdir gcc-9.3.0-build
cd gcc-9.3.0-build/
./../gcc-9.3.0/configure --disable-multilib --prefix=/home/andreagutierre/local --enable-languages='c c++'
make
make install
Change your .profile or .bashrc and add (use your own path):
export PATH=/home/andreagutierre/local/bin:$PATH
export LD_LIBRARY_PATH=/home/andreagutierre/local/lib64
export LIBRARY_PATH=/home/andreagutierre/local/lib64
export CC=/home/andreagutierre/local/bin/gcc
export CXX=/home/andreagutierre/local/bin/g++
Then check:
which gcc
~/local/bin/gcc
and:
gcc --version
gcc (GCC) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.