Compiling 10.07.p01 on Ubuntu 22.04

Dear Geant4 users,

I have been successfully using Geant4.10.07.p01 on an older computer with Ubuntu 20.04 LTS. I have recently tried to compile Geant4 on a newer system running Ubuntu 22.04 LTS with g++ version 11.2.0. When I try to compile Geant4 I receive the following error (just the top few lines shown) about the new declaration of fsqrt:

/home/david/src/geant4.10.07.p01/source/persistency/ascii/src/ error: ambiguating new declaration of ‘G4double fsqrt(G4double)’
73 | G4double fsqrt(G4double arg) { return std::sqrt(arg); }
| ^~~~~
In file included from /usr/include/c++/11/cmath:45,
from /usr/include/c++/11/complex:44,
from /home/david/src/geant4.10.07.p01/source/global/management/include/G4Types.hh:74,
from /home/david/src/geant4.10.07.p01/source/global/management/include/G4ios.hh:35,
from /home/david/src/geant4.10.07.p01/source/global/management/include/globals.hh:35,
from /home/david/src/geant4.10.07.p01/source/global/management/include/G4ThreeVector.hh:33,
from /home/david/src/geant4.10.07.p01/source/persistency/ascii/include/G4tgrEvaluator.hh:37,
from /home/david/src/geant4.10.07.p01/source/persistency/ascii/src/
/usr/include/x86_64-linux-gnu/bits/mathcalls-narrow.h:36:20: note: old declaration ‘float fsqrt(double)’
| ^~~~~~~~~~~~~~~
/home/david/src/geant4.10.07.p01/source/persistency/ascii/src/ In member function ‘void G4tgrEvaluator::AddCommonFunctions()’:
/home/david/src/geant4.10.07.p01/source/persistency/ascii/src/ error: no matching function for call to ‘setFunction(const char [5], float (&)(double) noexcept)’
95 | setFunction(“sqrt”, (*fsqrt));
| ~^~~~~~~~

Can anyone point me in the right direction to fix this compilation error?

Many thanks,


I got exactly the same error on the same platform, but with Geant4.10.06.p03.

Any clues?


Hi Fabio,

I’m afraid I don’t know what it causing the error.

Can someone else help?