Hi community.
I am trying to use all CERN ROOT functionalities in my Geant4 code. To do this, I added these lines to the Geant4 CMakeLists.txt file to specify the location of my CERN ROOT installation directory, etc.:
#----------------------------------------------------------------------------------------------------------
option(WITH_ROOT "Build DRAGON with ROOT" ON)
if(WITH_ROOT)
find_package(ROOT REQUIRED)
if(ROOT_FOUND)
STRING(REGEX MATCH "6.*" VERSION6MATCH ${ROOT_VERSION})
if(NOT VERSION6MATCH)
message(FATAL_ERROR "${name} requires ROOT 6")
endif()
endif()
if(EXISTS "${ROOT_DIR}/modules/RootNewMacros.cmake")
include("${ROOT_DIR}/modules/RootNewMacros.cmake")
endif()
endif()
if(WITH_ROOT)
include_directories(${ROOT_INCLUDE_DIRS})
target_link_libraries(DRAGON ${ROOT_LIBRARIES} ${Geant4_LIBRARIES})
#link_directories(${ROOT_LIBRARY_DIR})
endif()
#----------------------------------------------------------------------------------------------------------
and I get a lot of errors:
#----------------------------------------------------------------------------------------------------------
lcharon1991@lcharon1991-Lenovo-G40-70:~/Geant4/geant4work/BM3/DRAGON/DRAGON-build$ make
[ 2%] Building CXX object CMakeFiles/DRAGON.dir/src/DRAGONPrimaryGeneratorAction.cc.o
In file included from /home/lcharon1991/Documentos/ROOT/root_build/include/TString.h:28,
from /home/lcharon1991/Documentos/ROOT/root_build/include/TNamed.h:26,
from /home/lcharon1991/Documentos/ROOT/root_build/include/TAxis.h:24,
from /home/lcharon1991/Documentos/ROOT/root_build/include/TH1.h:24,
from /home/lcharon1991/Documentos/ROOT/root_build/include/TH1F.h:24,
from /home/lcharon1991/Geant4/geant4work/BM3/DRAGON/DRAGON/src/DRAGONPrimaryGeneratorAction.cc:46:
/home/lcharon1991/Documentos/ROOT/root_build/include/ROOT/RStringView.hxx:32:10: error: conflicting declaration of template ‘template<class _CharT, class _Traits> using basic_string_view = std::experimental::__ROOT::basic_string_view<_CharT, _Traits>’
32 | using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>;
| ^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/basic_string.h:48,
from /usr/include/c++/9/string:55,
from /usr/include/c++/9/bits/locale_classes.h:40,
from /usr/include/c++/9/bits/ios_base.h:41,
from /usr/include/c++/9/ios:42,
from /usr/include/c++/9/istream:38,
from /usr/include/c++/9/sstream:38,
from /usr/include/c++/9/complex:45,
from /home/lcharon1991/Geant4/Geant4/geant4_install/include/Geant4/G4Types.hh:74,
from /home/lcharon1991/Geant4/Geant4/geant4_install/include/Geant4/G4ios.hh:35,
from /home/lcharon1991/Geant4/Geant4/geant4_install/include/Geant4/globals.hh:35,
from /home/lcharon1991/Geant4/geant4work/BM3/DRAGON/DRAGON/include/DRAGONPrimaryGeneratorAction.hh:34,
from /home/lcharon1991/Geant4/geant4work/BM3/DRAGON/DRAGON/src/DRAGONPrimaryGeneratorAction.cc:30:
/usr/include/c++/9/string_view:90:11: note: previous declaration ‘template<class _CharT, class _Traits> class std::basic_string_view’
90 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
.
.
.
#---------------------------------------------------------------------------------------------------------------------------
How can I solve this issue?
Some extra and I think useful information:
- geant4-config --version
11.2.1 - root-config --version
6.22/09 - lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal - g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.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. - clang++ --version
clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Thanks a lot in advance.