# Namespace errors

**URL:** <https://root-forum.cern.ch/t/namespace-errors/45665>\
**Category:** Newbie\
**Tags:** build\
**Created:** [July 2, 2021, 5:52pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665 "2021-07-02T17:52:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/3ec8ea/32.png) [@Ronan](https://root-forum.cern.ch/u/Ronan)\
**Post date:** [July 2, 2021, 5:52pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/1 "2021-07-02T17:52:08Z")

</div>

_ROOT Version:_ 6.24/02  
_Platform:_ Ubuntu 20.04.2 (focal)  
_Compiler:_ Not Provided (uncertain)

* * *

Hello,

I am trying to `make` a program which depends on ROOT. I recently downloaded and built ROOT with the recommended setup, however added the `DCMAKE_CXX_STANDARD=17` flag as I thought this would fix my issue. Evidently it didn’t.

When I run `make` on my local program I get errors like

```auto
home/[...]/root_install/include/ROOT/RStringView.hxx(65): error: namespace "std" has no member "string_view"
/home/[...]/root_install/include/ROOT/RStringView.hxx(84): error: expected an operator
/home/[...]/root_install/include/TString.h(115): error: expected an operator
/home/[...]/root_install/include/TString.h(280): error: namespace "std" has no member "string_view"

```

Looking online this seems to stem from C++ version mismatch, but I thought I took care of that with the cmake flag in both ROOT and my local program (with `set(CXXFLAGS "${CXXFLAGS} -std=c++17")`)

I’m not sure what other information I should provide for this as I’m honestly not very familiar with this entire building process. If further info is needed please feel free to ask, if anybody know how I should go about fixing this issue I would greatly appreciate it.

Sincerely,

Ronan

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [July 2, 2021, 6:08pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/2 "2021-07-02T18:08:45Z")

</div>

> however added the DCMAKE\_CXX\_STANDARD=17

That flag is indeed require, however make sure you use it from the start. i.e. you need to start a build of ROOT from scratch with that option.

---

<div class="post-metadata">

**Author:** ![Ronan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/3ec8ea/32.png) [@Ronan](https://root-forum.cern.ch/u/Ronan)\
**Post date:** [July 2, 2021, 6:22pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/3 "2021-07-02T18:22:39Z")

</div>

If from scratch you mean right after the download this is what I did. Though if that is thought to be the reason why I have this issue I can try to build it again and see.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [July 2, 2021, 6:44pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/4 "2021-07-02T18:44:41Z")

</div>

The other potential reason is that the flag `-std=c++17` might not be used as expected in your build. So you should also examine the actual command line use to compile your local program.

---

<div class="post-metadata">

**Author:** ![Ronan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/3ec8ea/32.png) [@Ronan](https://root-forum.cern.ch/u/Ronan)\
**Post date:** [July 2, 2021, 8:32pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/5 "2021-07-02T20:32:48Z")

</div>

Ok, so I tried a rebuild which for some reason didn’t use C++17 but C++14 bbased of root-config output.

So just to be clear, my build command, following : [Building ROOT from source - ROOT](https://root.cern/install/build_from_source/)  
Should actually be:  
`cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=../root_install/ ../root_src/` correct? I see other posts mentioning `-Dcxx17=ON` ([Enable C++14/17 support after building ROOT](https://root-forum.cern.ch/t/enable-c-14-17-support-after-building-root/36735)) would this also be needed?

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [July 2, 2021, 8:55pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/6 "2021-07-02T20:55:16Z")

</div>

`cxx17` is the old way of configuring and `CMAKE_CXX_STANDARD` is the new way.

With v6.24/02, `CMAKE_CXX_STANDARD` should have worked. What did the configure step print?

---

<div class="post-metadata">

**Author:** ![Ronan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/3ec8ea/32.png) [@Ronan](https://root-forum.cern.ch/u/Ronan)\
**Post date:** [July 2, 2021, 9:22pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/7 "2021-07-02T21:22:58Z")

</div>

Ah, a re-build worked out fine so I assume I just made a typo or something. current output of `root-config --cflags` is `-pthread -std=c++17 -m64 -I/home/[...]/root_install/include`

I still get now the same initial issues, so it may be a build portion of the project I’m working with that’s an issue as you had mentioned earlier.

Hopefully without going too far off topic, if c++17 is required for this version of root, is there a reason why it is not recommended in the build page to use that argument? I may be misunderstanding the issue at hand.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [July 2, 2021, 10:25pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/8 "2021-07-02T22:25:48Z")

</div>

c++17 is not required. What is required is that your project and ROOT are build using the same C++ standard (either c++11, c++14 or c++17).

---

<div class="post-metadata">

**Author:** ![Ronan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/3ec8ea/32.png) [@Ronan](https://root-forum.cern.ch/u/Ronan)\
**Post date:** [July 14, 2021, 5:59pm UTC](https://root-forum.cern.ch/t/namespace-errors/45665/9 "2021-07-14T17:59:00Z")

</div>

Just a quick update. I did manage to resolve this by forcing ROOT to compile in C++11 which was in turn compatible with my other software, per pcanal’s guess.

Thank you for the help!
