# ROOT header files not found when compiling in Qt Creator

**URL:** <https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710>\
**Category:** ROOT\
**Tags:** cmake\
**Created:** [July 17, 2023, 1:47pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710 "2023-07-17T13:47:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![asarnats](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@asarnats](https://root-forum.cern.ch/u/asarnats)\
**Post date:** [July 17, 2023, 1:47pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/1 "2023-07-17T13:47:41Z")

</div>

Hi all,

I’m a summerstudent working on an existing code (C++) with Qt Creator. The goal is to embed a ROOT canvas within the Qt created application/program. There are two examples (similar to each other) that I’ve tried: `qtcanvas` from Github and `qtcanvas` from Gitlab.

If anyone experienced with ROOT and/or Qt knows what is breaking, or knows an alternative way implement ROOT in a QtWidget: your expertize would be greatly appreciated.

* * *

Both examples produce the following errors during compilation:

```auto
TCanvas.h: No such file or directory qtcanvas.hpp 13
TApplication.h: No such file or directory main.cpp 10

```

I’ve installed ROOT in `/usr/local/` and used `$ source /usr/local/root/bin/thisroot.h`. ROOT works on terminal and the headers and libraries are in place. I’ve tried different versions of Qt and different compilers; they produce the same error.

I’ve managed to solve this bug for the older version of `qtcanvas` (github), by adding the following lines to `CMakeList.txt`:

```auto
find_package(ROOT REQUIRED)
include(${ROOT_USE_FILE})

```

This produced 62 errors concerning `TString.h` , for example:

```auto
'string_view' in namespace 'std' does not name a type TString.h 291
expected type-specifier TString.h 118

```

An example of compile output:

```auto
/usr/local/root/include/RConfigure.h:30:4: warning: #warning is a GCC extension
   30 | # warning "The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues"
      | ^ ~~~~~~
/usr/local/root/include/RConfigure.h:30:4: warning: #warning "The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues" [-Wcpp]

```

Thank you in advance,  
Andrej

* * *

_ROOT Version:_ v6.28/04  
_Platform:_ Ubuntu v22.04  
_Compiler:_ GCC v11.3.0, Clang14 and MinGW  
_Qt Version:_ Qt v5.15.2 and v6.2.4

* * *

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 18, 2023, 10:57am UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/2 "2023-07-18T10:57:43Z")

</div>

Did you call `source thisroot.sh` before starting QtCreator from the terminal?

Try also out this example which uses more modern CMake commands: [ROOT · Modern CMake](https://cliutils.gitlab.io/modern-cmake/chapters/packages/ROOT.html)

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 18, 2023, 1:01pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/3 "2023-07-18T13:01:20Z")

</div>

Maybe share with us what is the “Build Environment” (make a screenshot) of the corresponding tab in QtCreator and “CMake configuration”. There should be some include\_path there pointing at the ROOT include headers.

Also, are the warnings just warnings, or are you getting a compilation error?

---

<div class="post-metadata">

**Author:** ![asarnats](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@asarnats](https://root-forum.cern.ch/u/asarnats)\
**Post date:** [July 18, 2023, 1:13pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/4 "2023-07-18T13:13:05Z")

</div>

I did call `$ source thisroot.sh` and it is in my `.bashrc`. When calling `$ root` it runs.

 ![Screenshot from 2023-07-18 15-06-53](https://root-forum.cern.ch/uploads/default/original/3X/c/a/caf7aee169656f28a92a7d8d753edada03d4ff19.png)  
 ![Screenshot from 2023-07-18 15-07-21](https://root-forum.cern.ch/uploads/default/original/3X/0/9/096d6cbcbf7994ac74f80087819fa656ed4ccbb1.png)  
 ![Screenshot from 2023-07-18 15-07-43](https://root-forum.cern.ch/uploads/default/original/3X/8/0/8011399c45b02901ccdbd64d67f33fa538a35996.png)  
 ![Screenshot from 2023-07-18 15-11-49](https://root-forum.cern.ch/uploads/default/original/3X/a/b/ab2454fdc2ef17b30bbc92017021b6fa883798eb.png)

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 18, 2023, 5:08pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/5 "2023-07-18T17:08:54Z")

</div>

Try the following fork to see if this one compiles for you:

> **[GitHub - ferdymercury/qtcanvas: Demonstration of incorporating a ROOT TCanvas...](https://github.com/ferdymercury/qtcanvas)**
>
> Demonstration of incorporating a ROOT TCanvas into a Qt window by wrapping the TCanvas in a QWidget. - GitHub - ferdymercury/qtcanvas: Demonstration of incorporating a ROOT TCanvas into a Qt window...

It works for me out of the box with Ubuntu22 and ROOT 6.26/10 and QtCreator 10.0.1

Cheers!

---

<div class="post-metadata">

**Author:** ![asarnats](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@asarnats](https://root-forum.cern.ch/u/asarnats)\
**Post date:** [July 19, 2023, 12:49pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/6 "2023-07-19T12:49:14Z")

</div>

Out of the box, I get the message that the cpp and hpp file cannot be found. I’ve changed the `.pro` file to include the directories `/src` and `/include`. Same thing has been done in the code, e.g. `#include "include\qtcanvas.hpp"`

Thereafter I get the `TCanvas.h` and `TApplication.h` errors. I tried it now on Windows 10, which has the same Qt Creator as you (10.0.2), and the errors persist.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 19, 2023, 1:06pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/7 "2023-07-19T13:06:17Z")

</div>

Please do no use any .pro file, just clone freshly the repository I mentioned. From QtCreator, open the CMakeLists.txt directly by clicking on File, Open File or Project, doble click on CMakeLists.txt.

---

<div class="post-metadata">

**Author:** ![asarnats](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@asarnats](https://root-forum.cern.ch/u/asarnats)\
**Post date:** [July 19, 2023, 2:00pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/8 "2023-07-19T14:00:23Z")

</div>

Thank you for your reply and help so far.

I get the following error on Ubuntu 22.04 (QtCreator 6.0.2):

 ![Screenshot from 2023-07-19 15-56-06](https://root-forum.cern.ch/uploads/default/original/3X/e/c/eca239c9067483116f919f4d28d464d88bfa908c.png)

Do I need to make a cmake configuration? I have no experience with this.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 19, 2023, 4:36pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/9 "2023-07-19T16:36:28Z")

</div>

QtCreator needs a “Kit” where you define what compiler and what cmake version you are going to use.

You have to specify that under Tools, Preferences, Kits.

See e.g. below, my “Kit” uses as CMake Tool /usr/local/bin/cmake and as generator “Ninja”.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/c/0/c0254bc17d199a002ea074833342bf7dc19f9ed0.png)

---

<div class="post-metadata">

**Author:** ![asarnats](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@asarnats](https://root-forum.cern.ch/u/asarnats)\
**Post date:** [July 25, 2023, 2:06pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/10 "2023-07-25T14:06:55Z")

</div>

Problem has been fixed by building ROOT from source, instead of using binaries.

Thanks everyone for the help.

---

<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:** [August 8, 2023, 2:07pm UTC](https://root-forum.cern.ch/t/root-header-files-not-found-when-compiling-in-qt-creator/55710/11 "2023-08-08T14:07:05Z")

</div>

Closed on August 8, 2023, 2:07pm UTC

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