Hi. I’m having issues when attempting to build Root from source (which I need to do to use the Genie neutrino simulator software). Below is my cmake command:
cmake --build . -- install -j4
And the rather large error I get:
[ 77%] Built target MetaCling
[ 77%] Built target rootcling_stage1
[ 77%] Generating G__Core.cxx, ../lib/Core.pcm
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:76:
/usr/include/c++/9/valarray:1214:5: error: exception specification in declaration does not match previous declaration
begin(valarray<_Tp>& __va) noexcept
^
/usr/include/c++/9/bits/range_access.h:104:31: note: previous declaration is here
template<typename _Tp> _Tp* begin(valarray<_Tp>&);
^
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:76:
/usr/include/c++/9/valarray:1224:5: error: exception specification in declaration does not match previous declaration
begin(const valarray<_Tp>& __va) noexcept
^
/usr/include/c++/9/bits/range_access.h:105:37: note: previous declaration is here
template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
^
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:76:
/usr/include/c++/9/valarray:1234:5: error: exception specification in declaration does not match previous declaration
end(valarray<_Tp>& __va) noexcept
^
/usr/include/c++/9/bits/range_access.h:106:31: note: previous declaration is here
template<typename _Tp> _Tp* end(valarray<_Tp>&);
^
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:76:
/usr/include/c++/9/valarray:1249:5: error: exception specification in declaration does not match previous declaration
end(const valarray<_Tp>& __va) noexcept
^
/usr/include/c++/9/bits/range_access.h:107:37: note: previous declaration is here
template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
^
input_line_1:1:10: fatal error: could not build module 'std'
#include <new>
~~~~~~~~^
Warning in cling::IncrementalParser::CheckABICompatibility():
Failed to extract C++ standard library version.
While building module 'Core':
While building module 'Cling_Runtime' imported from input_line_2:1:
While building module 'Cling_Runtime_Extra' imported from /home/archie/Documents/Software/root_build/etc/cling/Interpreter/RuntimeUniverse.h:27:
In file included from <module-includes>:1:
/home/archie/Documents/Software/root_build/etc/cling/Interpreter/DynamicExprInfo.h:13:10: fatal error: could not build module 'std'
#include <string>
~~~~~~~~^
/home/archie/Documents/Software/root_build/etc/cling/Interpreter/RuntimeUniverse.h:27:10: fatal error: could not build module 'Cling_Runtime_Extra'
#include "cling/Interpreter/Visibility.h"
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from input_line_3:1:
In file included from /home/archie/Documents/Software/root_build/etc/cling/lib/clang/13.0.0/include/assert.h:8:
In file included from /usr/include/assert.h:35:
In file included from /usr/include/features.h:510:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
# include <gnu/stubs-32.h>
^~~~~~~~~~~~~~~~
While building module 'Core':
While building module 'ROOT_Rtypes' imported from /home/archie/Documents/Software/root_build/include/Rtypes.h:23:
In file included from <module-includes>:1:
/home/archie/Documents/Software/root_build/include/RtypesCore.h:28:10: fatal error: could not build module 'std'
#include <cstddef> // size_t, NULL
~~~~~~~~^
/home/archie/Documents/Software/root_build/include/ThreadLocalStorage.h:60:10: fatal error: could not build module 'ROOT_Rtypes'
#include "RtypesCore.h"
~~~~~~~~^~~~~~~~~~~~~~
While building module 'Core':
While building module 'ROOT_Foundation_Stage1_NoRTTI' imported from /home/archie/Documents/Software/root_build/include/Rtypes.h:197:
In file included from <module-includes>:2:
/home/archie/Documents/Software/root_build/include/ROOT/RStringView.hxx:30:12: fatal error: could not build module 'std'
# include <experimental/string_view>
~~~~~~~~^
Error: Error loading the default rootcling header files.
gmake[2]: *** [core/CMakeFiles/G__Core.dir/build.make:472: core/G__Core.cxx] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:31338: core/CMakeFiles/G__Core.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
-- clad build command succeeded. See also /home/archie/Documents/Software/root_build/interpreter/cling/tools/plugins/clad/clad-prefix/src/clad-stamp/clad-build-*.log
[ 77%] Performing install step for 'clad'
-- clad install command succeeded. See also /home/archie/Documents/Software/root_build/interpreter/cling/tools/plugins/clad/clad-prefix/src/clad-stamp/clad-install-*.log
[ 77%] Completed 'clad'
[ 77%] Built target clad
gmake: *** [Makefile:156: all] Error 2
I’ve seen topics that discuss the same error, however no strong solutions are provided (eg. an old compiler bug, which I should not experience). Any help would be appreciated, cheers.
_ROOT Version: 6.30/02
_Platform: Ubuntu 22.04.3
_Compiler: gcc 9.5.0
If you mean the build of Root I used the defaults apart from mathmore and pythia6 being enabled, as I mentioned above. Otherwise my gcc version is 9.5. Would you recommend upgrading to a newer version to get C++17?
I went into the cmakecache txt file and changed the cxx from 14 to 17 (for some reason my machine doesn’t play nice if I don’t manually change them like this. My compiler flag then correctly had c++17 in it, but I got the same/similar error when attempting to build:
[ 77%] Built target MetaCling
[ 77%] Built target rootcling_stage1
[ 77%] Generating G__Core.cxx, ../lib/Core.pcm
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:79:
/usr/include/c++/9/valarray:1214:5: error: exception specification in declaration does not match previous declaration
begin(valarray<_Tp>& __va) noexcept
^
/usr/include/c++/9/bits/range_access.h:104:31: note: previous declaration is here
template<typename _Tp> _Tp* begin(valarray<_Tp>&);
^
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:79:
/usr/include/c++/9/valarray:1224:5: error: exception specification in declaration does not match previous declaration
begin(const valarray<_Tp>& __va) noexcept
^
/usr/include/c++/9/bits/range_access.h:105:37: note: previous declaration is here
template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
^
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:79:
/usr/include/c++/9/valarray:1234:5: error: exception specification in declaration does not match previous declaration
end(valarray<_Tp>& __va) noexcept
^
/usr/include/c++/9/bits/range_access.h:106:31: note: previous declaration is here
template<typename _Tp> _Tp* end(valarray<_Tp>&);
^
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:79:
/usr/include/c++/9/valarray:1249:5: error: exception specification in declaration does not match previous declaration
end(const valarray<_Tp>& __va) noexcept
^
/usr/include/c++/9/bits/range_access.h:107:37: note: previous declaration is here
template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
^
input_line_1:1:10: fatal error: could not build module 'std'
#include <new>
~~~~~~~~^
Warning in cling::IncrementalParser::CheckABICompatibility():
Failed to extract C++ standard library version.
While building module 'Core':
While building module 'Cling_Runtime' imported from input_line_2:1:
While building module 'Cling_Runtime_Extra' imported from /home/archie/Documents/Software/root_build/etc/cling/Interpreter/RuntimeUniverse.h:27:
In file included from <module-includes>:1:
/home/archie/Documents/Software/root_build/etc/cling/Interpreter/DynamicExprInfo.h:13:10: fatal error: could not build module 'std'
#include <string>
~~~~~~~~^
/home/archie/Documents/Software/root_build/etc/cling/Interpreter/RuntimeUniverse.h:27:10: fatal error: could not build module 'Cling_Runtime_Extra'
#include "cling/Interpreter/Visibility.h"
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from input_line_3:1:
In file included from /home/archie/Documents/Software/root_build/etc/cling/lib/clang/13.0.0/include/assert.h:8:
In file included from /usr/include/assert.h:35:
In file included from /usr/include/features.h:510:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
# include <gnu/stubs-32.h>
^~~~~~~~~~~~~~~~
While building module 'Core':
While building module 'ROOT_Rtypes' imported from /home/archie/Documents/Software/root_build/include/Rtypes.h:23:
In file included from <module-includes>:1:
/home/archie/Documents/Software/root_build/include/RtypesCore.h:28:10: fatal error: could not build module 'std'
#include <cstddef> // size_t, NULL
~~~~~~~~^
/home/archie/Documents/Software/root_build/include/ThreadLocalStorage.h:60:10: fatal error: could not build module 'ROOT_Rtypes'
#include "RtypesCore.h"
~~~~~~~~^~~~~~~~~~~~~~
While building module 'Core':
While building module 'ROOT_Foundation_Stage1_NoRTTI' imported from /home/archie/Documents/Software/root_build/include/Rtypes.h:197:
In file included from <module-includes>:2:
/home/archie/Documents/Software/root_build/include/ROOT/RStringView.hxx:25:10: fatal error: could not build module 'std'
#include <string_view>
~~~~~~~~^
Error: Error loading the default rootcling header files.
gmake[2]: *** [core/CMakeFiles/G__Core.dir/build.make:472: core/G__Core.cxx] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:31338: core/CMakeFiles/G__Core.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
-- clad build command succeeded. See also /home/archie/Documents/Software/root_build/interpreter/cling/tools/plugins/clad/clad-prefix/src/clad-stamp/clad-build-*.log
[ 77%] Performing install step for 'clad'
-- clad install command succeeded. See also /home/archie/Documents/Software/root_build/interpreter/cling/tools/plugins/clad/clad-prefix/src/clad-stamp/clad-install-*.log
[ 77%] Completed 'clad'
[ 77%] Built target clad
gmake: *** [Makefile:156: all] Error 2
For a new user, you should be ideally installing most of the C++ toolchains with sudo apt install build-essential which is the distro defaults, while there are other versions of GCC about, the distro packages are usually all built to a single standard that doesn’t change until the next release, which for Ubuntu 22.04 is GCC11.
Since ROOT is very picky with the build system you use, it needs to remain constant and match all other packages you’re using it with; and the assumption is you’re using the defaults, the build package lists are also all assuming the defaults too. So you’d have to manually replace things such as C++11 header packages with C++9 instead, which won’t be spelled out for you on most instructions.
At a high level, I’d recommend resetting your build environment and starting with build-essential rather than explicitly choosing a GCC release, it’d get you much more aligned with the implicit assumptions.
No, please don’t do this. You should pass the option to CMake, and if there are errors that might indicates potential incompatibilities with your system and need to be addressed.
Ah ok, apologies. Here’s the error (I assume this is how you pass it?):
$ cmake -DCMAKE_CXX_STANDARD=17
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
CMake Error: The source directory "/home/archie/Documents/Software/root_build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.