Error when building root 6.30/02 on Ubuntu 22.04.3

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


Welcome to the ROOT Forum!
How did you configure ROOT (i.e. which CMake options did you specify)?

On Ubuntu 22.04, you should have GCC 11.4 (NOT 9.5).

Defaults apart from mathmore and pythia6 being enabled (and the pythia6 lib directory being specified).

Yes I downgraded to get around some issues with installing Genie dependencies.

Can you make sure you have -std:c++17 (or so) in your C++ compiler flags? Otherwise maybe @Axel has an idea of what could be the issue…

How would one go about checking this, I’m pretty new to linux and c++ I’m afraid.

At the end of the CMake configure step, it prints the compiler flags. For example on Windows it prints:

System          Windows-10.0.22621
Processor       8 core AMD Ryzen 7 5700G with Radeon Graphics  (AMD64)
Build type
Install path    C:/Program Files/ROOT
Compiler        MSVC 19.38.33130.0
Compiler flags:
C               -nologo -IC:/root-dev/git/master/build/win -FIw32pragma.h -FIsehmap.h -MD -EHsc- -W3 -wd4267 -DNOMINMAX
C++             -nologo -IC:/root-dev/git/master/build/win -FIw32pragma.h -FIsehmap.h -Zc:__cplusplus -std:c++17 -MD -GR -EHsc- -W3 -wd4141 -wd4291 -wd4244 -wd4049 -wd4146 -wd4250 -wd4624 -wd4267 -D_XKEYCHECK_H -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING

Linker flags:
Executable      /machine:x64
Module          /machine:x64 -ignore:4049,4206,4217,4221 -incremental:no
Shared          /machine:x64 -ignore:4049,4206,4217,4221 -incremental:no

-- Enabled support for:  asimage builtin_afterimage builtin_cfitsio builtin_clang builtin_cling builtin_freetype builtin_ftgl builtin_gl2ps builtin_glew builtin_gtest builtin_llvm builtin_lz4 builtin_lzma builtin_nlohmannjson builtin_openui5 builtin_pcre builtin_tbb builtin_unuran builtin_xxhash builtin_zlib builtin_zstd clad dataframe fftw3 fitsio gdml http imt mathmore odbc opengl proof pyroot pythia8 roofit webgui root7 shared sqlite tmva tmva-cpu tmva-pymva spectrum unuran xml
-- Configuring done (10.3s)
-- Generating done (27.4s)

(under Compiler flags: C++)

Yeah I’ve got -std:c++14

6.30 requires C++17, so this is the issue. How did you configure your build?

1 Like

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?

Try to specify -DCMAKE_CXX_STANDARD=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.

Ok that makes sense. How would one go about resetting?

No, you must add -DCMAKE_CXX_STANDARD=17 to the list of options you specify when configuring ROOT.

EDIT: Or type $ cmake -DCMAKE_CXX_STANDARD=17 . in the build directory (note the dot at the end)

Thanks again. Tried the second command (which took), and then attempted to run the install again; sadly the same error at the same place.

So it’s maybe due to your version of GCC