You are not logged in.

#1 2018-11-23 10:19:28

tlaik
Member
From: Tallinn
Registered: 2018-11-22
Posts: 3

Missing headers in QT Creator examples [SOLVED]

After installing full qt5 group, qt5-declarative and qtcreator, I tried to get some of the example projects running.
I've done so by selecting them in the Qt Creator examples menu with "copy project" option into a newly created directory.
It seems that none of the examples will work (tried four so far), because some of their headers are missing. For example, the Analog Clock example fails with "../analogclock/main.cpp:53:10: fatal error: rasterwindow.h: No such file or directory".
I do have this file in /usr/share/doc/qt/examples/gui/rasterwindow/rasterwindow.h, and I could copy it over. However, I think I'm clearly missing something big here. Perhaps some directories in PATH or other env vars haven't been set properly, or maybe something is missing in config files.

The settings of my default Kit are as follows: https://i.imgur.com/UAuAEgl.png
Rest of the settings haven't been changed from their default values.

Perhaps this topic (also) belongs to Qt forums, but I decided to ask here since I could only look up few missing header Qt problems, many of which happened years ago, and were mostly due to incomplete / broken installs, which didn't apply to me.

Last edited by tlaik (2018-11-24 23:54:18)

Offline

#2 2018-11-23 12:11:15

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Missing headers in QT Creator examples [SOLVED]

$ head -1 /usr/share/doc/qt/examples/gui/analogclock/analogclock.pro
include(../rasterwindow/rasterwindow.pri)

After copying the .pro file, you need to either adjust this path or put a copy of the rasterwindow directory next to the analogclock dir.

According to the docs, you don't need to copy the project just to build it. Edit: just tried this and it suggests to copy the project anyway. So I said, okay, go ahead and copy it, and then Creator crashed ... though it did manage to copy the directory first (without handling the rasterwindow dependency).

Last edited by Raynman (2018-11-23 12:16:22)

Offline

#3 2018-11-23 12:50:37

tlaik
Member
From: Tallinn
Registered: 2018-11-22
Posts: 3

Re: Missing headers in QT Creator examples [SOLVED]

When I choose the "Keep project" option, it does pick up required includes and headers.

However, it produces various errors about write failure (lacking permissions, since those files are owned by root):

/usr/lib/qt/mkspecs/features/toolchain.prf:215: error: Cannot write cache file /usr/share/doc/qt/examples/gui/analogclock/.qmake.stash: Permission denied

Also, in this case cannot change the configuration file of the project for the same reason - it's not owned by me.

All in all, I could just copy missing example files manually in each case and make it work. I'm just wondering if there is some major mis-configuration in play here.

Edit: So far, the best method indeed seems to be to copy files manually. I think the easiest option is to copy all examples at once into your preferred directory, like

cp -r /usr/share/doc/qt/examples/* /mnt/d/qt/

.
After that, you can simply open those projects in Qt Creator instead of creating them through the menu.

I'll spend a bit more time checking the results, and if it's all fine, I'll mark this as solved.

Last edited by tlaik (2018-11-23 14:56:40)

Offline

#4 2018-11-23 15:04:45

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,911

Re: Missing headers in QT Creator examples [SOLVED]

I'm just wondering if there is some major mis-configuration in play here.

../analogclock/main.cpp
include(../rasterwindow/rasterwindow.pri

Looks more like bad coding practices to me.

using paths starting with .. only works if the entire directory tree one level higher is copied/moved .
copy the whole examples tree , then try to build and it will work again.

Last edited by Lone_Wolf (2018-11-23 15:06:02)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#5 2018-11-23 15:30:25

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Missing headers in QT Creator examples [SOLVED]

tlaik wrote:

I'm just wondering if there is some major mis-configuration in play here.

If you're asking "Should Creator be smarter about this? Is there an option I missed?" or "Are examples that depend on other examples supposed to use relative paths?", I think you might have a better chance of finding somebody who knows about this on the Qt forums (or mailing lists).

But copying all examples (or at least any dependencies) is indeed easy to do and also allows you to experiment and make changes.

Offline

#6 2018-11-24 23:53:32

tlaik
Member
From: Tallinn
Registered: 2018-11-22
Posts: 3

Re: Missing headers in QT Creator examples [SOLVED]

Alright, if other more Qt-development specific problems arise, I'll be asking at their place.
As for this particular case, making a copy of entire examples folder does indeed solve the compilation problems.

Offline

Board footer

Powered by FluxBB