Question about compiling root with c++ 17

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?


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 ...                                                                               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/                                               /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’

You need to (re)build your ROOT completely from scratch again (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

How to create application

See, for example:

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?

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

error still exist

So you still have C++ standard mismatch somewhere.