# Question about compiling root with c++ 17

**URL:** <https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597>\
**Category:** Newbie\
**Tags:** cmake\
**Created:** [September 18, 2022, 12:46am UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597 "2022-09-18T00:46:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Chan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/colin_chan/32/30180_2.png) [@Colin\_Chan](https://root-forum.cern.ch/u/Colin_Chan)\
**Post date:** [September 18, 2022, 12:46am UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597/1 "2022-09-18T00:46:48Z")

</div>

My system wsl Ubuntu 20  
Root version 6.24  
default c++ compiler version :9.4

My PI wants me to do the testing for a DAQ project on the local machine. And the error message tells me to compile ROOT with c++17. I follow the instruction of “building root from the source” by changing `"target_compile_features(${library} INTERFACE cxx_std_${CMAKE_CXX_STANDARD})"` into `"target_compile_features(${library} INTERFACE cxx_std_${CMAKE_CXX_STANDARD=17})"` ( this line of code is at root/cmake/RootMacros.cmake). However, the issue still exists. What should I do?

Thanks

```auto
Generating dictonary...
                                                                                 Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with __GLIBCXX__'20200808' Extraction of runtime standard library version was: '20210601' Warning: Unused class rule: mdaq::eventTimes Making libMilliDAQ.so ... In file included from /home/zheng/root_milidaq17/root/include/TString.h:29, from ./interface/Logger.h:11, from ./interface/DemonstratorConfiguration.h:11, from src/DemonstratorConfiguration.cc:1: /home/zheng/root_milidaq17/root/include/ROOT/RStringView.hxx:32:37: error: ‘experimental’ in namespace std’ does not name a type 32 | using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>; | ^ ~~~~~~~~~~~/home/zheng/root_milidaq17/root/include/ROOT/RStringView.hxx:35:12: error: ‘basic_string_view’ does not name a type 35 | typedef basic_string_view<char> string_view; | ^~~~~~~~~~~~~~~~~ /home/zheng/root_milidaq17/root/include/ROOT/RStringView.hxx:36:12: error: ‘basic_string_view’ does not name a type 36 | typedef basic_string_view<char16_t> u16string_view; | ^ ~~~~~~~~~~~~~~~~/home/zheng/root_milidaq17/root/include/ROOT/RStringView.hxx:37:12: error: ‘basic_string_view’ does not name a type 37 | typedef basic_string_view<char32_t> u32string_view; | ^~~~~~~~~~~~~~~~~ /home/zheng/root_milidaq17/root/include/ROOT/RStringView.hxx:38:12: error: ‘basic_string_view’ does not name a type 38 | typedef basic_string_view<wchar_t> wstring_view; | ^ ~~~~~~~~~~~~~~~~ /home/zheng/root_milidaq17/root/include/ROOT/RStringView.hxx:48:4: warning: inline variables are only available with ‘-std=c++17’ or ‘-std=gnu++17’

```

---

<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 18, 2022, 6:56am UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597/2 "2022-09-18T06:56:17Z")

</div>

You need to [(re)build your ROOT completely from scratch again](https://root.cern/install/#build-from-source) (i.e., remove the old “`root_build`” and “`root_install`” directories).  
When configuring it, use something like this:  
`cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=../root_install ../root_src`

---

<div class="post-metadata">

**Author:** ![Himanshu\_Kumar](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/himanshu_kumar/32/30891_2.png) [@Himanshu\_Kumar](https://root-forum.cern.ch/u/Himanshu_Kumar)\
**Post date:** [September 18, 2022, 10:44am UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597/3 "2022-09-18T10:44:59Z")

</div>

How to create application

---

<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 18, 2022, 11:30am UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597/4 "2022-09-18T11:30:12Z")

</div>

See, for example:

- [ROOT Manual → Basics → Creating a user application with ROOT](https://root.cern/manual/creating_a_user_application/)
- [ROOT Manual → Basics → Integrating ROOT into CMake projects](https://root.cern/manual/integrate_root_into_my_cmake_project/)

---

<div class="post-metadata">

**Author:** ![Colin\_Chan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/colin_chan/32/30180_2.png) [@Colin\_Chan](https://root-forum.cern.ch/u/Colin_Chan)\
**Post date:** [September 19, 2022, 6:04am UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597/5 "2022-09-19T06:04:09Z")

</div>

I follow your instruction. Unfortunately, the error for c++ 17 still exists. Do you think that my default c++ compiler 9.4.0 version is the cause of the trouble? What else can I do?  
Thanks

---

<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 19, 2022, 6:46am UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597/6 "2022-09-19T06:46:24Z")

</div>

After you built ROOT, you need to (re)build your libraries completely from scratch again, with the same C++ standard as ROOT uses.  
You can take compiler flags provided by: `root-config --cflags`

---

<div class="post-metadata">

**Author:** ![Colin\_Chan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/colin_chan/32/30180_2.png) [@Colin\_Chan](https://root-forum.cern.ch/u/Colin_Chan)\
**Post date:** [September 19, 2022, 3:10pm UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597/7 "2022-09-19T15:10:01Z")

</div>

error still exist

---

<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 19, 2022, 3:43pm UTC](https://root-forum.cern.ch/t/question-about-compiling-root-with-c-17/51597/8 "2022-09-19T15:43:53Z")

</div>

So you still have C++ standard mismatch somewhere.
