# Including root in Qt6

**URL:** <https://root-forum.cern.ch/t/including-root-in-qt6/45863>\
**Category:** Newbie\
**Created:** [July 15, 2021, 2:04pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863 "2021-07-15T14:04:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andr](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Andr](https://root-forum.cern.ch/u/Andr)\
**Post date:** [July 15, 2021, 2:04pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/1 "2021-07-15T14:04:56Z")

</div>

Did anyone try to include ROOT in a Qt6 application?  
For me upgrading from Qt5 to Qt6 breaks compilation. Just including TString.h in main.cpp and adding TString a = “a” produces 4000k+ errors.  
In Qt5 everything works, and I did try c++11/c++14/c++17 flags.  
Any (even very wild) suggestions are very welcomed! 🙂

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [July 15, 2021, 2:15pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/2 "2021-07-15T14:15:28Z")

</div>

Hi @Andr,

I am not aware of ROOT supporting Qt 6 (maybe @bellenot knows more details). I am curious to see those errors anyway. Any chance of attaching the compiler output here?

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [July 15, 2021, 2:19pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/3 "2021-07-15T14:19:26Z")

</div>

Sorry, I have no idea (and FYI, ROOT & Qt is not officially supported)

---

<div class="post-metadata">

**Author:** ![Andr](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Andr](https://root-forum.cern.ch/u/Andr)\
**Post date:** [July 15, 2021, 2:42pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/4 "2021-07-15T14:42:00Z")

</div>

Mostly they are conflicting declarations  
Example (no other code except TString a = “a”):  
/opt/root/include/ROOT/RStringView.hxx:32: error: conflicting declaration of template ‘template\<class \_CharT, class \_Traits\> using basic\_string\_view = std::experimental::\_\_ROOT::basic\_string\_view\<\_CharT, \_Traits\>’  
/opt/root/include/ROOT/RStringView.hxx:32:10: error: conflicting declaration of template ‘template\<class \_CharT, class \_Traits\> using basic\_string\_view = std::experimental::\_\_ROOT::basic\_string\_view\<\_CharT, \_Traits\>’  
32 | using basic\_string\_view = ::std::experimental::basic\_string\_view\<\_CharT,\_Traits\>;  
| ^ ~~~~~~~~~~~~~~~~

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 15, 2021, 4:13pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/5 "2021-07-15T16:13:34Z")

</div>

I have application, where Qt6 and ROOT used together.  
Most probably, you have mismatch in C++ standards between ROOT and Qt6.  
Please check your qt project file.

---

<div class="post-metadata">

**Author:** ![Andr](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Andr](https://root-forum.cern.ch/u/Andr)\
**Post date:** [July 15, 2021, 4:28pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/6 "2021-07-15T16:28:11Z")

</div>

Thank you Sergej,  
Can you be more specific please? What should I check? The compile flag (c++ version) has no effect.  
Andrey

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 15, 2021, 4:39pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/7 "2021-07-15T16:39:14Z")

</div>

If you are using qt project file, it should have line like:

```auto
CONFIG+=c++11

```

It should match with ROOT C++ standard.

---

<div class="post-metadata">

**Author:** ![Andr](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Andr](https://root-forum.cern.ch/u/Andr)\
**Post date:** [July 15, 2021, 4:43pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/8 "2021-07-15T16:43:17Z")

</div>

That’s what I meant - I have already tested with c++11, c++14 and c++17, the result is the same.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 15, 2021, 4:49pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/9 "2021-07-15T16:49:57Z")

</div>

That output have your `root-config --cflags`  
And can you check that is `CXXFLAGS` in generated by qt makefile

Actually, I compile my project with qt6 using cmake.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 15, 2021, 4:53pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/10 "2021-07-15T16:53:52Z")

</div>

And normally I using c++17 when building ROOT

---

<div class="post-metadata">

**Author:** ![Andr](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Andr](https://root-forum.cern.ch/u/Andr)\
**Post date:** [July 15, 2021, 5:10pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/11 "2021-07-15T17:10:19Z")

</div>

Did not help too:  
I have put all the flags from the root-config --cflags to .pro file using QMAKE\_CXXFLAGS  
The ROOT binaries were downloaded directly from the root download page for Ubuntu20.04

Most (if not all) of the errors are “conflicting declarations” in the ROOT templates, I still have no idea what can it be, never had such problems with Qt5.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 15, 2021, 5:25pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/12 "2021-07-15T17:25:42Z")

</div>

> [@Andr](#):
>
> I have put all the flags from the root-config --cflags to .pro file using QMAKE\_CXXFLAGS

Can you check inside generated makefile? Probably Qt adds own settings.

Your symptoms indicating that you try to compile ROOT headers with different C++ standard.

---

<div class="post-metadata">

**Author:** ![Andr](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Andr](https://root-forum.cern.ch/u/Andr)\
**Post date:** [July 15, 2021, 8:55pm UTC](https://root-forum.cern.ch/t/including-root-in-qt6/45863/13 "2021-07-15T20:55:10Z")

</div>

Thank you Sergej!  
I have tested that the syntax of c++11 does not stop the code form compilation (when Root is not imported)
