TString.h Comilation errors due to C++ version despite ROOT having been compiled with correct version

Dear all,

I am trying to compile some code using ROOT 6.22.00 on LXPLUS. I have sourced the following:
source /cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc10-opt/setup.sh

I get the following error with TString.h:

In file included from /cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TMatrixTBase.h:73,
                 from /cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TMatrixT.h:23,
                 from /cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TMatrixD.h:20,
                 from /cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TDecompBase.h:26,
                 from /cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TDecompLU.h:21,
                 from /afs/cern.ch/work/c/cschloes/T2K/new_test_intallation/xsLLhFitter/src/utils/src/../include/CalcChisq.hh:7,
                 from /afs/cern.ch/work/c/cschloes/T2K/new_test_intallation/xsLLhFitter/src/utils/src/CalcChisq.cc:1:
/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TString.h:834:53: error: ‘string_view’ in namespace ‘std’ does not name a type
  834 | inline Bool_t operator==(const char *s1, const std::string_view &s2)
      |                                                     ^~~~~~~~~~~
/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TString.h:834:48: note: ‘std::string_view’ is only available from C++17 onwards
  834 | inline Bool_t operator==(const char *s1, const std::string_view &s2)
      |                                                ^~~
/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TString.h:834:15: error: ‘Bool_t operator==(const char*, const int&)’ must have an argument of class or enumerated type
  834 | inline Bool_t operator==(const char *s1, const std::string_view &s2)
      |               ^~~~~~~~
/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TString.h:839:37: error: ‘string_view’ in namespace ‘std’ does not name a type
  839 | inline Bool_t operator==(const std::string_view &s1, const char *s2)
      |                                     ^~~~~~~~~~~
/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TString.h:839:32: note: ‘std::string_view’ is only available from C++17 onwards
  839 | inline Bool_t operator==(const std::string_view &s1, const char *s2)
      |                                ^~~
/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TString.h:839:15: error: ‘Bool_t operator==(const int&, const char*)’ must have an argument of class or enumerated type
  839 | inline Bool_t operator==(const std::string_view &s1, const char *s2)
      |               ^~~~~~~~
/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TString.h:852:37: error: ‘string_view’ in namespace ‘std’ does not name a type
  852 |   std::string printValue(const std::string_view* val);
      |                                     ^~~~~~~~~~~
/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include/TString.h:852:32: note: ‘std::string_view’ is only available from C++17 onwards
  852 |   std::string printValue(const std::string_view* val);
      |                                ^~~
make[2]: *** [src/utils/CMakeFiles/xslfutils.dir/src/CalcChisq.cc.o] Error 1
make[1]: *** [src/utils/CMakeFiles/xslfutils.dir/all] Error 2
make: *** [all] Error 2

I thought it was because ROOT had not been compiled with the same C++ version but when I use root-config --cflags, I get the following:

-pthread -std=c++17 -m64 -I/cvmfs/sft.cern.ch/lcg/releases/ROOT/v6.22.00-be0a0/x86_64-centos7-gcc10-opt/include

I am also compiling using cmake -DCMAKE_CXX_VERSION=c++17.

Do you know what I might be doing wrong?

Many thanks in advance!!

ROOT Version: 6.22.00
Platform: LCG_98python3/x86_64-centos7-gcc10-opt
Compiler: cmake version 3.17.3


Maybe: cmake -DCMAKE_CXX_STANDARD=17

Thank you for the suggestion. I just tried it but unfortunately it still gives me the same error.

It could be that your “some code” needs some special flag.
It could also be that it does not support “c++17” at all (e.g., it supports at most “c++14” or “c++11”).

For example, newer Geant 4 supports (note also “=14”): cmake -DGEANT4_BUILD_CXXSTD=14
Older Geant 4 supports (note also “=c++11”): cmake -DGEANT4_BUILD_CXXSTD=c++11

Thanks for the reply. I managed to solve the issue by sourcing the following:

source /cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc10-opt/setup.sh
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.06/x86_64-centos7-gcc48-opt/bin/thisroot.sh

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