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

**URL:** <https://root-forum.cern.ch/t/tstring-h-comilation-errors-due-to-c-version-despite-root-having-been-compiled-with-correct-version/46995>\
**Category:** ROOT\
**Tags:** cmake\
**Created:** [September 25, 2021, 6:48pm UTC](https://root-forum.cern.ch/t/tstring-h-comilation-errors-due-to-c-version-despite-root-having-been-compiled-with-correct-version/46995 "2021-09-25T18:48:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cschloes](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/ba8739/32.png) [@cschloes](https://root-forum.cern.ch/u/cschloes)\
**Post date:** [September 25, 2021, 6:48pm UTC](https://root-forum.cern.ch/t/tstring-h-comilation-errors-due-to-c-version-despite-root-having-been-compiled-with-correct-version/46995/1 "2021-09-25T18:48:23Z")

</div>

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:

```auto
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:

```auto
-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

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 25, 2021, 7:43pm UTC](https://root-forum.cern.ch/t/tstring-h-comilation-errors-due-to-c-version-despite-root-having-been-compiled-with-correct-version/46995/2 "2021-09-25T19:43:27Z")

</div>

Maybe: `cmake -DCMAKE_CXX_STANDARD=17`

---

<div class="post-metadata">

**Author:** ![cschloes](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/ba8739/32.png) [@cschloes](https://root-forum.cern.ch/u/cschloes)\
**Post date:** [September 26, 2021, 5:53am UTC](https://root-forum.cern.ch/t/tstring-h-comilation-errors-due-to-c-version-despite-root-having-been-compiled-with-correct-version/46995/3 "2021-09-26T05:53:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 26, 2021, 8:58am UTC](https://root-forum.cern.ch/t/tstring-h-comilation-errors-due-to-c-version-despite-root-having-been-compiled-with-correct-version/46995/4 "2021-09-26T08:58:54Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![cschloes](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/ba8739/32.png) [@cschloes](https://root-forum.cern.ch/u/cschloes)\
**Post date:** [September 27, 2021, 10:48am UTC](https://root-forum.cern.ch/t/tstring-h-comilation-errors-due-to-c-version-despite-root-having-been-compiled-with-correct-version/46995/5 "2021-09-27T10:48:03Z")

</div>

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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [October 11, 2021, 10:48am UTC](https://root-forum.cern.ch/t/tstring-h-comilation-errors-due-to-c-version-despite-root-having-been-compiled-with-correct-version/46995/6 "2021-10-11T10:48:08Z")

</div>

Closed on October 11, 2021, 10:48am UTC

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