AnaEx02 not compiling in G4 11.0.0

I’m trying to write ntuples in my simulation, I’m using Geant4 11.0.0.
I’m working on CentOS stream 8 with gcc compiler 8.5.0.
I built Geant wit the following configuration:

> cmake3 -DCMAKE_INSTALL_PREFIX=/opt/Geant4/Geant4-11.0.0 ../geant4-v11.0.0/ -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_QT=ON -DGEANT4_INSTALL_DATA=ON -DGEANT4_BUILD_MULTITHREADED=true -DGEANT4_USE_GDML=ON

and I’m using ROOT from epel:

Name         : root
Version      : 6.24.06
Release      : 2.el8
Architecture : x86_64
Size         : 257 k
Source       : root-6.24.06-2.el8.src.rpm
Repository   : @System
From repo    : epel

the compilation error I get on AnaEx02 is the following:

Consolidate compiler generated dependencies of target AnaEx01
[ 33%] Built target AnaEx01
Consolidate compiler generated dependencies of target exampleB1Con
[ 66%] Built target exampleB1Con
Consolidate compiler generated dependencies of target AnaEx02
[ 70%] Building CXX object AnaEx02/CMakeFiles/AnaEx02.dir/src/HistoManager.cc.o
In file included from /usr/include/root/TString.h:29,
                 from /usr/include/root/TNamed.h:26,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/root/ROOT/RStringView.hxx:32:84: error: conflicting declaration of template ‘template<class _CharT, class _Traits> using basic_string_view = std::experimental::fundamentals_v1::basic_string_view<_CharT, _Traits>’
    using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>;
                                                                                    ^
In file included from /usr/include/c++/8/bits/basic_string.h:48,
                 from /usr/include/c++/8/string:52,
                 from /usr/include/root/TSchemaHelper.h:17,
                 from /usr/include/root/TGenericClassInfo.h:21,
                 from /usr/include/root/Rtypes.h:191,
                 from /usr/include/root/TObject.h:17,
                 from /usr/include/root/TNamed.h:25,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/string_view:71:11: note: previous declaration ‘template<class _CharT, class _Traits> class std::basic_string_view’
     class basic_string_view
           ^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8/memory:74,
                 from /usr/include/root/ROOT/TypeTraits.hxx:15,
                 from /usr/include/root/TString.h:30,
                 from /usr/include/root/TNamed.h:26,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h:53:16: error: ‘_Lock_policy’ does not name a type
   static const _Lock_policy __default_lock_policy =
                ^~~~~~~~~~~~
In file included from /usr/include/c++/8/cstddef:49,
                 from /usr/include/root/RtypesCore.h:28,
                 from /usr/include/root/Rtypes.h:23,
                 from /usr/include/root/TObject.h:17,
                 from /usr/include/root/TNamed.h:25,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h: In function ‘void std::__throw_concurrence_lock_error()’:
/usr/include/c++/8/ext/concurrence.h:102:5: error: ‘__concurrence_lock_error’ was not declared in this scope
   { _GLIBCXX_THROW_OR_ABORT(__concurrence_lock_error()); }
     ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:102:5: note: suggested alternative:
In file included from /usr/include/c++/8/memory:74,
                 from /usr/include/root/ROOT/TypeTraits.hxx:15,
                 from /usr/include/root/TString.h:30,
                 from /usr/include/root/TNamed.h:26,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h:67:9: note:   ‘__gnu_cxx::__concurrence_lock_error’
   class __concurrence_lock_error : public std::exception
         ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8/cstddef:49,
                 from /usr/include/root/RtypesCore.h:28,
                 from /usr/include/root/Rtypes.h:23,
                 from /usr/include/root/TObject.h:17,
                 from /usr/include/root/TNamed.h:25,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h: In function ‘void std::__throw_concurrence_unlock_error()’:
/usr/include/c++/8/ext/concurrence.h:106:5: error: ‘__concurrence_unlock_error’ was not declared in this scope
   { _GLIBCXX_THROW_OR_ABORT(__concurrence_unlock_error()); }
     ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:106:5: note: suggested alternative:
In file included from /usr/include/c++/8/memory:74,
                 from /usr/include/root/ROOT/TypeTraits.hxx:15,
                 from /usr/include/root/TString.h:30,
                 from /usr/include/root/TNamed.h:26,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h:75:9: note:   ‘__gnu_cxx::__concurrence_unlock_error’
   class __concurrence_unlock_error : public std::exception
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8/cstddef:49,
                 from /usr/include/root/RtypesCore.h:28,
                 from /usr/include/root/Rtypes.h:23,
                 from /usr/include/root/TObject.h:17,
                 from /usr/include/root/TNamed.h:25,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h: In function ‘void std::__throw_concurrence_broadcast_error()’:
/usr/include/c++/8/ext/concurrence.h:111:5: error: ‘__concurrence_broadcast_error’ was not declared in this scope
   { _GLIBCXX_THROW_OR_ABORT(__concurrence_broadcast_error()); }
     ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:111:5: note: suggested alternative:
In file included from /usr/include/c++/8/memory:74,
                 from /usr/include/root/ROOT/TypeTraits.hxx:15,
                 from /usr/include/root/TString.h:30,
                 from /usr/include/root/TNamed.h:26,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h:83:9: note:   ‘__gnu_cxx::__concurrence_broadcast_error’
   class __concurrence_broadcast_error : public std::exception
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8/cstddef:49,
                 from /usr/include/root/RtypesCore.h:28,
                 from /usr/include/root/Rtypes.h:23,
                 from /usr/include/root/TObject.h:17,
                 from /usr/include/root/TNamed.h:25,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h: In function ‘void std::__throw_concurrence_wait_error()’:
/usr/include/c++/8/ext/concurrence.h:115:5: error: ‘__concurrence_wait_error’ was not declared in this scope
   { _GLIBCXX_THROW_OR_ABORT(__concurrence_wait_error()); }
     ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:115:5: note: suggested alternative:
In file included from /usr/include/c++/8/memory:74,
                 from /usr/include/root/ROOT/TypeTraits.hxx:15,
                 from /usr/include/root/TString.h:30,
                 from /usr/include/root/TNamed.h:26,
                 from /usr/include/root/TAxis.h:24,
                 from /usr/include/root/TH1.h:24,
                 from /usr/include/root/TH1D.h:24,
                 from /home/stroili/tmp/Geant4/analysis/AnaEx02/src/HistoManager.cc:33:
/usr/include/c++/8/ext/concurrence.h:91:9: note:   ‘__gnu_cxx::__concurrence_wait_error’
   class __concurrence_wait_error : public std::exception
         ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h: In member function ‘void __gnu_cxx::__mutex::lock()’:
/usr/include/c++/8/ext/concurrence.h:153:6: error: ‘__throw_concurrence_lock_error’ was not declared in this scope
      __throw_concurrence_lock_error();
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:153:6: note: suggested alternative:
/usr/include/c++/8/ext/concurrence.h:101:3: note:   ‘std::__throw_concurrence_lock_error’
   __throw_concurrence_lock_error()
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h: In member function ‘void __gnu_cxx::__mutex::unlock()’:
/usr/include/c++/8/ext/concurrence.h:164:6: error: ‘__throw_concurrence_unlock_error’ was not declared in this scope
      __throw_concurrence_unlock_error();
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:164:6: note: suggested alternative:
/usr/include/c++/8/ext/concurrence.h:105:3: note:   ‘std::__throw_concurrence_unlock_error’
   __throw_concurrence_unlock_error()
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h: In member function ‘void __gnu_cxx::__recursive_mutex::lock()’:
/usr/include/c++/8/ext/concurrence.h:208:6: error: ‘__throw_concurrence_lock_error’ was not declared in this scope
      __throw_concurrence_lock_error();
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:208:6: note: suggested alternative:
/usr/include/c++/8/ext/concurrence.h:101:3: note:   ‘std::__throw_concurrence_lock_error’
   __throw_concurrence_lock_error()
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h: In member function ‘void __gnu_cxx::__recursive_mutex::unlock()’:
/usr/include/c++/8/ext/concurrence.h:219:6: error: ‘__throw_concurrence_unlock_error’ was not declared in this scope
      __throw_concurrence_unlock_error();
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:219:6: note: suggested alternative:
/usr/include/c++/8/ext/concurrence.h:105:3: note:   ‘std::__throw_concurrence_unlock_error’
   __throw_concurrence_unlock_error()
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h: At global scope:
/usr/include/c++/8/ext/concurrence.h:234:13: error: ‘__mutex’ does not name a type
     typedef __mutex __mutex_type;
             ^~~~~~~
/usr/include/c++/8/ext/concurrence.h:237:5: error: ‘__mutex_type’ does not name a type; did you mean ‘__mutex’?
     __mutex_type& _M_device;
     ^~~~~~~~~~~~
     __mutex
/usr/include/c++/8/ext/concurrence.h:243:40: error: expected ‘)’ before ‘&’ token
     explicit __scoped_lock(__mutex_type& __name) : _M_device(__name)
                           ~            ^
                                        )
/usr/include/c++/8/ext/concurrence.h: In destructor ‘__gnu_cxx::__scoped_lock::~__scoped_lock()’:
/usr/include/c++/8/ext/concurrence.h:247:7: error: ‘_M_device’ was not declared in this scope
     { _M_device.unlock(); }
       ^~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:247:7: note: suggested alternative: ‘__dev_t’
     { _M_device.unlock(); }
       ^~~~~~~~~
       __dev_t
/usr/include/c++/8/ext/concurrence.h: At global scope:
/usr/include/c++/8/ext/concurrence.h:291:15: error: ‘__mutex’ has not been declared
     void wait(__mutex *mutex)
               ^~~~~~~
/usr/include/c++/8/ext/concurrence.h:301:25: error: ‘__recursive_mutex’ has not been declared
     void wait_recursive(__recursive_mutex *mutex)
                         ^~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h: In member function ‘void __gnu_cxx::__cond::broadcast()’:
/usr/include/c++/8/ext/concurrence.h:286:6: error: ‘__throw_concurrence_broadcast_error’ was not declared in this scope
      __throw_concurrence_broadcast_error();
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8/ext/concurrence.h:286:6: note: suggested alternative:
/usr/include/c++/8/ext/concurrence.h:110:3: note:   ‘std::__throw_concurrence_broadcast_error’
   __throw_concurrence_broadcast_error()
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and so on.

I get the same kind of behaviour on an old simulation I developed in G4 10.x and that was working.

Thank you for your help.

Roberto

Hi. I’m guessing a bit here. I see a reference to AnaEx01 in your above compilation of AnaEx02. AnaEx01 uses g4Analysis rather than Root. If you somehow used the CMakeLists.txt file from AnaEx01 (or part of it) when compiling AnaEx02, you would not properly link Root which might explain your errors when compiling HistoManager.cc. I would suggest you do a fresh copy of the AnaEx02 folder from the distribution, then rerun cmake and make.

I have Geant4 11.0.0 installed with essentially the same options as you and I am using Root 6.24.06. My build file for AnaEx02 is attached. My build was successful and there is no mention of AnaEx01 (as I would expect).
AnaEx02_compile_log.txt (2.7 KB)

Dear John, thank you for your reply, but unfortunately it didn’t solve my problem.
The fact that you see also An01 compiled comes from the fact that I compiled all the three examples in the analysis directory altogether from the top directory.
In any case I repeated the build on only the An02 example and I get the same compilation error and there’s no trace of An01 in that compilation.
build.txt (870.1 KB)

Your problem seems to be when attempting to link with Root. You are using Root 6.24.06. Was it compiled with the C++17 standard? (When compiling Root, it defaults to the compiler default or C++11 if the compiler default is older than 11. Geant4 v11 default compilation is C++17.) I think Root and Geant4 should be compiled with the same standard.

I’m using root from the epel distribution, I think it was compiled with C++14, unfortunately Geant4 11 cannot be compiled with C++ lower than 17

You can always download the Root 6.24.06 source tar ball from the Root home directory and install it locally. That way you can compile it to the C++17 standard. (That is what I do, even though Fedora 35 has a distribution of Root 6.24.06 available through dnf.) Just make sure that your references to Root point to your local install, not the epel install.