qtmqtt make error on linux: "qmqttglobal.h: No such file or directory"
-
@SGaist Just checked, it was using from /usr/bin
which qmake
/usr/bin/qmakefind ~/ -type f -executable -name 'qmake'
/home/test/Qt/5.11.0/android_x86/bin/qmake
/home/test/Qt/5.11.0/gcc_64/bin/qmake
/home/test/Qt/5.11.0/android_armv7/bin/qmakeSo trying the second one now-
/home/test/Qt/5.11.0/gcc_64/bin/qmake -version
QMake version 3.1
Using Qt version 5.11.0 in /home/test/Qt/5.11.0/gcc_64/libcd qtmqtt-5.11
On using this qt I am getting a different error:/home/test/Qt/5.11.0/gcc_64/bin/qmake -r
Info: creating stash file /home/test/Documents/qtmqtt-5.11/.qmake.stash Info: creating cache file /home/test/Documents/qtmqtt-5.11/.qmake.cache Reading /home/test/Documents/qtmqtt-5.11/src/src.pro Reading /home/test/Documents/qtmqtt-5.11/src/mqtt/mqtt.pro Reading /home/test/Documents/qtmqtt-5.11/examples/examples.pro Reading /home/test/Documents/qtmqtt-5.11/examples/mqtt/mqtt.pro Project ERROR: You cannot build examples inside the Qt source tree, except as part of a proper Qt build.
Update: On running it again, it worked!
/home/test/Qt/5.11.0/gcc_64/bin/qmake -rReading /home/test/Documents/qtmqtt-5.11/src/src.pro Reading /home/test/Documents/qtmqtt-5.11/src/mqtt/mqtt.pro Reading /home/test/Documents/qtmqtt-5.11/examples/examples.pro Reading /home/test/Documents/qtmqtt-5.11/examples/mqtt/mqtt.pro Reading /home/test/Documents/qtmqtt-5.11/examples/mqtt/simpleclient/simpleclient.pro Reading /home/test/Documents/qtmqtt-5.11/examples/mqtt/subscriptions/subscriptions.pro Reading /home/test/Documents/qtmqtt-5.11/examples/mqtt/quicksubscription/quicksubscription.pro Reading /home/test/Documents/qtmqtt-5.11/examples/mqtt/websocketsubscription/websocketsubscription.pro Reading /home/test/Documents/qtmqtt-5.11/tests/tests.pro Reading /home/test/Documents/qtmqtt-5.11/tests/auto/auto.pro Reading /home/test/Documents/qtmqtt-5.11/tests/auto/cmake/cmake.pro Reading /home/test/Documents/qtmqtt-5.11/tests/auto/conformance/conformance.pro Reading /home/test/Documents/qtmqtt-5.11/tests/auto/qmqttcontrolpacket/qmqttcontrolpacket.pro Reading /home/test/Documents/qtmqtt-5.11/tests/auto/qmqttclient/qmqttclient.pro Reading /home/test/Documents/qtmqtt-5.11/tests/auto/qmqttsubscription/qmqttsubscription.pro Reading /home/test/Documents/qtmqtt-5.11/tests/auto/qmqtttopicname/qmqtttopicname.pro Reading /home/test/Documents/qtmqtt-5.11/tests/auto/qmqtttopicfilter/qmqtttopicfilter.pro Reading /home/test/Documents/qtmqtt-5.11/tests/benchmarks/benchmarks.pro Reading /home/test/Documents/qtmqtt-5.11/tests/benchmarks/qmqttclient/qmqttclient.pro
Now
make
andsudo make install
has finished building.
The directory/usr/lib/x86_64-linux-gnu/qtmqtt-5.11/
is now created
Will test with sample app now. -
For changing the qmake, I replaced
/usr/bin/qmake
with new one using following command-sudo mv /usr/bin/qmake /usr/bin/qmake.old sudo ln -s /home/test/Qt/5.11.0/gcc_64/bin/qmake /usr/bin/qmake qmake -version QMake version 3.1 Using Qt version 5.11.0 in /home/test/Qt/5.11.0/gcc_64/lib
Now when I opened the qtmqtt-5.11 folder in qt creator, it first gave this warning:
Project ERROR: Module does not define version. Error while parsing file /home/test/Documents/qtmqtt-5.11/src/mqtt/mqtt.pro. Giving up. Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version. Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point. Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!
Still proceeded to "Build all" and it worked. But now on doing "Run" -
I get this error:
In file included from /home/test/Documents/qtmqtt-5.11/examples/mqtt/simpleclient/main.cpp:51:0:
/home/test/Documents/qtmqtt-5.11/examples/mqtt/simpleclient/mainwindow.h:55:23: fatal error: QMqttClient: No such file or directory
-
You should do out of source builds. This keeps the source clean and allows you to nuke the build folder if something goes wrong.
Do not change your distribution provided qmake. Use the full path to the version you want to use. You can be sure that you are going to hit a wall once you update Qt to a newer version.
-
Actually I tried the same procedure on a different PC, but it is not working on it.
It is showing theQtMqtt/qmqttglobal.h
not found error. I think it bypassed it in mine because yesterday I had tried building by manually adding aQtMqtt/
directory inside~/Qt/5.11.0/gcc_64/include/
ls ~/Qt/5.11.0/gcc_64/include/QtMqtt/
qmqttclient.h qmqttconnection_p.h qmqttglobal.h qmqttmessage.h qmqttsubscription.h qmqtttopicfilter.cpp qmqtttopicname.cpp QMqttClient qmqttclient_p.h qmqttcontrolpacket.cpp QMqttMessage QMqttSubscription qmqttsubscription_p.h qmqtttopicfilter.h qmqtttopicname.h qmqttclient.cpp qmqttconnection.cpp qmqttcontrolpacket_p.h qmqttmessage.cpp qmqttsubscription.cpp QMqttTopicFilter QMqttTopicName QtMqttDepends
echo ~/Qt/5.11.0/gcc_64/include/QtCore/5.11.0/QtCore/private/qmqtt*
/home/test/Qt/5.11.0/gcc_64/include/QtCore/5.11.0/QtCore/private/qmqttclient_p.h (omitted) /private/qmqttconnection_p.h (omitted) /private/qmqttcontrolpacket_p.h (omitted) /private/qmqttsubscription_p.h
-
@SGaist Yes, I should use the full path. But If I am using it just for testing this one project right now, then I guess it should be fine(?)
About build folder - okay I'll do it from next time. Currently to restart the build I was deleting qtmqtt folder and extracting the zip again.Also, how can I get this 1 reputation to be able to reply faster
-
You are invoking Murphy's Law.
I'd recommend doing that now so you ensure that you have a full correct build also when calling make install.
To get a +1 somebody has to upvote one of your question or answer.
-
@udayraj123 said in qmqtt make error on linux: "qmqttglobal.h: No such file or directory":
QtMqtt
Hi,
The reason behind the problem is the QtMqtt header files were not inside the default system include folders, when you run the make it will only take the external header files from the system include directories like /usr/include . /usr/share/include . etc,. . Here you installed the QtMqtt inside your home which is not a regular location of included. You are not telling the make that you need to include the header from a folder inside your home.Solution 1 : You may set the INCLUDE_PATH in your environment variable in shell , or, update the build configuration https://doc-snapshots.qt.io/qtcreator-4.0/creator-build-settings.html
Soluton 2 : Install QtMqtt as root user with prefix=/usr , this may be easy
-
Thanks for your solutions, I'll try them, but I have some doubts-
QtMqtt header files were not inside the default system include folders...
Shouldn't this be a problem for all then? Is it building on your system without having to do the suggested change?
Here you installed the QtMqtt inside your home which is not a regular location of included
What location would you suggest for installing it?
Install QtMqtt as root user with prefix=/usr , this may be easy
I did not get the 'prefix=/usr' part.
-
@udayraj123 said in qtmqtt make error on linux: "qmqttglobal.h: No such file or directory":
Thanks for your solutions, I'll try them, but I have some doubts-
QtMqtt header files were not inside the default system include folders...
Shouldn't this be a problem for all then? Is it building on your system without having to do the suggested change?
No, because you're not doing a system install. These headers should be found in the Qt installation you used to build the module after you called
make install
.Here you installed the QtMqtt inside your home which is not a regular location of included
What location would you suggest for installing it?
Using the correct
qmake
executable, it should install the module in the correct folders.Install QtMqtt as root user with prefix=/usr , this may be easy
I did not get the 'prefix=/usr' part.
When doing a full Qt build, you can configure where the installation should happen. You are not concerned by this.
-
@udayraj123 said in qtmqtt make error on linux: "qmqttglobal.h: No such file or directory":
Download zip from https://github.com/qt/qtmqtt
I can confirm that using the .zip download from such location gave me same errors as you mention (I'm using Lubuntu 18.04 / Qt 5.11)
However cloning https://code.qt.io/qt/qtmqtt.git and doing:
qmake -r qmake make sudo make install
led to QtMQTT module built Ok and installed along other existing modules in my Qt installation so later on you could use the module in any application (i.e. provided examples or your own).