Home | News | Documentation | Download

ROOT 6_24_06 not compiling with c++17

I’m trying to compile ROOT 6_24_06 with c++17
The steps that I follow are:

  1. create “myBuild” directory
  2. enter in myBuild and run cmake -D roofit=ON -D minuit2=ON -Dcxx=17 …
  3. apparently, that’s not enough, and I have to run “ccmake …” to change the compiler from 14 to 17
    I change CMAKE_CXX_STANDARD 17
    and
    CXX_STANDARD_STRING 17
  4. run “cmake --build . -j48”

And I get the error that I reported.
By the way, there are other errors in dataframes but I removed them from the compilation hoping that would solve the whole story

[ 94%] Building CXX object graf3d/eve7/CMakeFiles/ROOTEve.dir/src/REveViewer.cxx.o
cd /home/testbeam/root_v6_24_06/myBuild/graf3d/eve7 && /opt/rh/devtoolset-8/root/usr/bin/c++ -DHTTP_WITHOUT_FASTCGI -DNO_SSL_DL -DUSE_WEBSOCKET -I/home/testbeam/root_v6_24_06/graf3d/eve7/inc -I/home/testbeam/root_v6_24_06/core/unix/inc -I/home/testbeam/root_v6_24_06/core/foundation/v7/inc -I/home/testbeam/root_v6_24_06/core/base/v7/inc -I/home/testbeam/root_v6_24_06/core/clingutils/inc -I/home/testbeam/root_v6_24_06/core/textinput/inc -I/home/testbeam/root_v6_24_06/core/thread/inc -I/home/testbeam/root_v6_24_06/core/zip/inc -I/home/testbeam/root_v6_24_06/core/rint/inc -I/home/testbeam/root_v6_24_06/core/clib/inc -I/home/testbeam/root_v6_24_06/core/meta/inc -I/home/testbeam/root_v6_24_06/core/gui/inc -I/home/testbeam/root_v6_24_06/core/cont/inc -I/home/testbeam/root_v6_24_06/core/foundation/inc -I/home/testbeam/root_v6_24_06/core/base/inc -I/home/testbeam/root_v6_24_06/myBuild/ginclude -I/home/testbeam/root_v6_24_06/math/physics/inc -I/home/testbeam/root_v6_24_06/math/matrix/inc -I/home/testbeam/root_v6_24_06/math/mathcore/v7/inc -I/home/testbeam/root_v6_24_06/math/mathcore/inc -I/home/testbeam/root_v6_24_06/core/imt/inc -I/home/testbeam/root_v6_24_06/core/multiproc/inc -I/home/testbeam/root_v6_24_06/tree/treeplayer/inc -I/home/testbeam/root_v6_24_06/hist/hist/inc -I/home/testbeam/root_v6_24_06/tree/tree/inc -I/home/testbeam/root_v6_24_06/graf3d/csg/inc -I/home/testbeam/root_v6_24_06/builtins -I/home/testbeam/root_v6_24_06/graf3d/eve7 -I/home/testbeam/root_v6_24_06/geom/geom/inc -I/home/testbeam/root_v6_24_06/io/io/v7/inc -I/home/testbeam/root_v6_24_06/io/io/inc -I/home/testbeam/root_v6_24_06/net/net/inc -I/home/testbeam/root_v6_24_06/montecarlo/eg/inc -I/home/testbeam/root_v6_24_06/graf2d/gpad/inc -I/home/testbeam/root_v6_24_06/graf2d/graf/inc -I/home/testbeam/root_v6_24_06/graf3d/g3d/inc -I/home/testbeam/root_v6_24_06/gui/webdisplay/inc -I/home/testbeam/root_v6_24_06/net/http/inc -I/home/testbeam/root_v6_24_06/gui/browserv7/inc -I/home/testbeam/root_v6_24_06/gui/browsable/inc -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O3 -DNDEBUG -fPIC -std=c++17 -MD -MT graf3d/eve7/CMakeFiles/ROOTEve.dir/src/REveViewer.cxx.o -MF CMakeFiles/ROOTEve.dir/src/REveViewer.cxx.o.d -o CMakeFiles/ROOTEve.dir/src/REveViewer.cxx.o -c /home/testbeam/root_v6_24_06/graf3d/eve7/src/REveViewer.cxx
/home/testbeam/root_v6_24_06/graf3d/eve7/src/REveCaloData.cxx: In member function ‘virtual Int_t ROOT::Experimental::REveCaloData::WriteCoreJson(nlohmann::json&, Int_t)’:
/home/testbeam/root_v6_24_06/graf3d/eve7/src/REveCaloData.cxx:268:29: error: no match for ‘operator=’ (operand types are ‘nlohmann::basic_json<>::value_type’ {aka ‘nlohmann::basic_json<>’} and ‘TString’)
       slice["name"]     = s.fName;
                             ^~~~~
In file included from /home/testbeam/root_v6_24_06/graf3d/eve7/inc/ROOT/REveElement.hxx:21,
                 from /home/testbeam/root_v6_24_06/graf3d/eve7/inc/ROOT/REveCaloData.hxx:16,
                 from /home/testbeam/root_v6_24_06/graf3d/eve7/src/REveCaloData.cxx:12:
/home/testbeam/root_v6_24_06/builtins/nlohmann/json.hpp:18662:17: note: candidate: ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::operator=(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>]’
     basic_json& operator=(basic_json other) noexcept (
                 ^~~~~~~~
/home/testbeam/root_v6_24_06/builtins/nlohmann/json.hpp:18662:17: note:   no known conversion for argument 1 from ‘TString’ to ‘nlohmann::basic_json<>’

_ROOT Version: 6_24_06
_Platform: CENTOS7
_Compiler: GCC 8.3.1


Hi @mauroroot ,
can you try starting from an empty build directory and only using CMAKE_CXX_STANDARD=17? That’s how we build ROOT for C++17, e.g. cmake -DCMAKE_CXX_STANDARD=17 -Droofit=ON -Dminuit2=ON ..

Cheers,
Enrico

Hi Enrico, unfortunately, I get the same error. This time I didn’t disable dataframe.
The first error is the following:

[ 91%] Building CXX object roofit/roofitcore/CMakeFiles/RooFitCore.dir/src/RooMultiVarGaussian.cxx.o
cd /home/testbeam/root_v6_24_06/myBuild/roofit/roofitcore && /opt/rh/devtoolset-8/root/usr/bin/c++  -I/home/testbeam/root_v6_24_06/roofit/roofitcore/inc -I/home/testbeam/root_v6_24_06/core/unix/inc -I/home/testbeam/root_v6_24_06/core/foundation/v7/inc -I/home/testbeam/root_v6_24_06/core/base/v7/inc -I/home/testbeam/root_v6_24_06/core/clingutils/inc -I/home/testbeam/root_v6_24_06/core/textinput/inc -I/home/testbeam/root_v6_24_06/core/thread/inc -I/home/testbeam/root_v6_24_06/core/zip/inc -I/home/testbeam/root_v6_24_06/core/rint/inc -I/home/testbeam/root_v6_24_06/core/clib/inc -I/home/testbeam/root_v6_24_06/core/meta/inc -I/home/testbeam/root_v6_24_06/core/gui/inc -I/home/testbeam/root_v6_24_06/core/cont/inc -I/home/testbeam/root_v6_24_06/core/foundation/inc -I/home/testbeam/root_v6_24_06/core/base/inc -I/home/testbeam/root_v6_24_06/myBuild/ginclude -I/home/testbeam/root_v6_24_06/hist/hist/inc -I/home/testbeam/root_v6_24_06/math/mathcore/v7/inc -I/home/testbeam/root_v6_24_06/math/mathcore/inc -I/home/testbeam/root_v6_24_06/core/imt/inc -I/home/testbeam/root_v6_24_06/core/multiproc/inc -I/home/testbeam/root_v6_24_06/math/matrix/inc -I/home/testbeam/root_v6_24_06/graf2d/graf/inc -I/home/testbeam/root_v6_24_06/io/io/v7/inc -I/home/testbeam/root_v6_24_06/io/io/inc -I/home/testbeam/root_v6_24_06/core/clib/res -I/home/testbeam/root_v6_24_06/builtins -I/usr/include/freetype2 -I/home/testbeam/root_v6_24_06/tree/tree/inc -I/home/testbeam/root_v6_24_06/math/minuit/inc -I/home/testbeam/root_v6_24_06/math/foam/inc -I/home/testbeam/root_v6_24_06/math/smatrix/inc -I/home/testbeam/root_v6_24_06/roofit/batchcompute/inc -I/home/testbeam/root_v6_24_06/net/net/inc -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O3 -DNDEBUG -fPIC -fno-math-errno -std=c++17 -MD -MT roofit/roofitcore/CMakeFiles/RooFitCore.dir/src/RooMultiVarGaussian.cxx.o -MF CMakeFiles/RooFitCore.dir/src/RooMultiVarGaussian.cxx.o.d -o CMakeFiles/RooFitCore.dir/src/RooMultiVarGaussian.cxx.o -c /home/testbeam/root_v6_24_06/roofit/roofitcore/src/RooMultiVarGaussian.cxx
/home/testbeam/root_v6_24_06/tree/dataframe/src/RLoopManager.cxx: In function ‘void {anonymous}::ExploreBranch(TTree&, std::set<std::basic_string<char> >&, ROOT::Detail::RDF::ColumnNames_t&, TBranch*, std::string, std::string&)’:
/home/testbeam/root_v6_24_06/tree/dataframe/src/RLoopManager.cxx:114:89: error: call of overloaded ‘basic_string(TString)’ is ambiguous
          UpdateList(bNamesReg, bNames, std::string(branchDirectlyFromTree->GetFullName()), friendName);
                                                                                         ^
In file included from /opt/rh/devtoolset-8/root/usr/include/c++/8/string:52,
                 from /home/testbeam/root_v6_24_06/core/meta/inc/TSchemaHelper.h:17,
                 from /home/testbeam/root_v6_24_06/core/meta/inc/TGenericClassInfo.h:21,
                 from /home/testbeam/root_v6_24_06/core/base/inc/Rtypes.h:191,
                 from /home/testbeam/root_v6_24_06/tree/dataframe/inc/ROOT/RDF/RColumnReaderBase.hxx:14,
                 from /home/testbeam/root_v6_24_06/tree/dataframe/inc/ROOT/RDataSource.hxx:14,
                 from /home/testbeam/root_v6_24_06/tree/dataframe/src/RLoopManager.cxx:2:
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/basic_string.h:3571:7: note: candidate: ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
       basic_string(basic_string&& __str)
       ^~~~~~~~~~~~
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/basic_string.h:3554:7: note: candidate: ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
       ^~~~~~~~~~~~
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/basic_string.h:3507:7: note: candidate: ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
       basic_string(const basic_string& __str);
       ^~~~~~~~~~~~

I started from scratch. I mean, I deleted the root directory and un-tar again the file.
I ran: cmake -D roofit=ON -D minuit2=ON -DCMAKE_CXX_STANDARD=17 ..
Do you have any suggestion on how to proceed?
Many thanks,

  • Mauro.

Ah, I see you are using devtoolset as compiler toolchain. That’s not supported (see the latest posts on the forum that mention “devtoolset”) , @Axel might be able to give you more details.

To get a ROOT with C++17 support on CentOS7 you can install it with conda, snap and I think also nix, see Installing ROOT - ROOT .

Cheers,
Enrico

Hi Enrico,
ok understood. If I want to compile the sources myself, what do you suggest to do?

  • Mauro.

Besides changing distro :grimacing: …you can install a more recent compiler in a conda environment or maybe through EPEL and compile ROOT with that toolchain. I don’t have other ideas but others might.

As a side comment, using recent software (or equivalently recent C++ standards) with CentOS is a pain because CentOS is just not the right distro for it. It sacrifices recency for stability. And CentOS7 is not even the latest version of the distro :slight_smile:

Cheers,
Enrico

Hi Enrico,
Do you mean I can install devtools, something like 10?
or devtools is not supported at all?

I’m using CENTOS7 because I think that’s the one supported at CERN (?)

Many thanks,

  • Mauro.

Devtools are not supported, but you can get a recent compiler (i.e. with C++17 support) via conda or maybe via EPEL repos (not sure) or via other package managers such as spack or nix. Then you can compile ROOT with that compiler.

I’m not sure what you mean with “supported”. lxplus and lxbatch (the most common computing clusters used at CERN, I think) indeed use CentOS7 but then most software stacks are compiled independently of the CentOS7 system packages and are provided via CVMFS/spack/LCG releases etc.
There is also lxplus8 which uses CentOS8. ROOT supports CentOS7 with its system compiler (supports as in: we test the releases on it, test nightly builds on it and provide packages for it), but the system compiler is a very old gcc version that does not support C++17.

Hi Enrico,
I did the very same steps with devtools-10 and it compiled.

  • Mauro.

Good to know, thanks!

Hi, sorry to bother you again with this.
I have another package that uses ROOT
As I said ROOT is now compiled with c++17 standard
But when I compile this other package I still get this error:

[ 91%] Built target euCliMergerMixedDuplicateMimosaTrigID
make[2]: Leaving directory '/home/testbeam/eudaq-v2/build'
make[2]: Leaving directory '/home/testbeam/eudaq-v2/build'
In file included from /home/testbeam/root_v6_22_08/myBuild/include/TString.h:28,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TNamed.h:26,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TAxis.h:24,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TH1.h:24,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TH1I.h:24,
                 from /home/testbeam/eudaq/monitors/onlinemon/include/MonitorPerformanceHistos.hh:11,
                 from /home/testbeam/eudaq/monitors/onlinemon/src/MonitorPerformanceHistos.cc:8:
/home/testbeam/root_v6_22_08/myBuild/include/ROOT/RStringView.hxx:84:17: error: expected type-specifier
   84 |        operator std::string_view() const { return std::string_view(fData,fLength); }
      |                 ^~~
In file included from /home/testbeam/root_v6_22_08/myBuild/include/TString.h:28,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TNamed.h:26,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TAxis.h:24,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TH1.h:24,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TH1F.h:24,
                 from /home/testbeam/eudaq/monitors/onlinemon/src/../include/EUDAQMonitorHistos.hh:11,
                 from /home/testbeam/eudaq/monitors/onlinemon/src/EUDAQMonitorHistos.cc:8:
/home/testbeam/root_v6_22_08/myBuild/include/ROOT/RStringView.hxx:84:17: error: expected type-specifier
   84 |        operator std::string_view() const { return std::string_view(fData,fLength); }
      |                 ^~~
In file included from /home/testbeam/root_v6_22_08/myBuild/include/TString.h:28,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TNamed.h:26,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TAxis.h:24,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TH1.h:24,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TH2.h:24,
                 from /home/testbeam/root_v6_22_08/myBuild/include/TH2I.h:24,
                 from /home/testbeam/eudaq/monitors/onlinemon/include/BaseCollection.hh:11,
                 from /home/testbeam/eudaq/monitors/onlinemon/src/BaseCollection.cc:8:
/home/testbeam/root_v6_22_08/myBuild/include/ROOT/RStringView.hxx:84:17: error: expected type-specifier
   84 |        operator std::string_view() const { return std::string_view(fData,fLength); }
      |                 ^~~

The problem seems to be related to ROOT
My guess is that I’m not properly configuring the cmake of the other package?
Is there an option that I need to set in order to do things properly?
Many thanks,

  • Mauro.

The other package needs to be compiled with C++17 as well, is that the case? You can check the compile options that are used e.g. inspecting the output of make VERBOSE=1.

Cheers,
Enrico

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.