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/G4tgrEvaluator.cc:73:10: 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/G4tgrEvaluator.cc:31:
/usr/include/x86_64-linux-gnu/bits/mathcalls-narrow.h:36:20: note: old declaration ‘float fsqrt(double)’
36 | __MATHCALL_NARROW (__MATHCALL_NAME (sqrt), __MATHCALL_REDIR_NAME2 (sqrt), 1);
| ^~~~~~~~~~~~~~~
/home/david/src/geant4.10.07.p01/source/persistency/ascii/src/G4tgrEvaluator.cc: In member function ‘void G4tgrEvaluator::AddCommonFunctions()’:
/home/david/src/geant4.10.07.p01/source/persistency/ascii/src/G4tgrEvaluator.cc:95:14: 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,

David

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

Any clues?

Thanks,
Fabio

Hi Fabio,

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

Can someone else help?

Thanks,

David