Undefined Reference CMake

Hello Everyone,

Since few days I’m using an old Geant4 version ( 10.06 ) in a powerful computer to upgrade my calculating power.
When I use CMake, an error appears :

/usr/bin/ld : CMakeFiles/exampleB4a.dir/exampleB4a.cc.o : In the function « main » :
/projet/ execute /exampleB4a.cc:81 : undefined reference to « B4DetectorConstruction::B4DetectorConstruction() »
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/exampleB4a.dir/build.make:220 : exampleB4a] Erreur 1
make[1]: *** [CMakeFiles/Makefile2:76 : CMakeFiles/exampleB4a.dir/all] Erreur 2

This is so strange because in my computer , using AppleClang 12.0. it works perfectly !
I don’t know if you have any ideas of where the error comes from…It seems like the code is compiling bu there is a failure in order to Link it.

Thank You very much for taking time to read this, I’m stuck since few days…
I’m certainly not give enough information so do not hesitate to ask me !

Best regards,


Which Geant4 version are you using on your Mac, and what is the OS/compiler/version on this other platform? It looks like your using/modifiying the B4a example, what modifications have you made to the B4DetectorConstruction constructors and the CMakeLists.txt file?

Thank you for your answer. I’m using the 10.7.1 version. The error is fixed. At least it was an error of the type definition of B4DetectorConstruction in the .hh…
Thank !