qt install qmatt library steps, personal experience, record

A few days ago, I wanted to simulate the connection between Internet of things terminals and Alibaba cloud on win10 computer. I wanted to find a software tool to try, but I had to pay for it... I can't find the right one!

ε = ('οο ')) well, I have to do it myself. After thinking about it, I'd like to use QT (my version is 5.9.8). The QT interface is easier to do, and there are many recently used QT interfaces. I think QT is still broad in all aspects. However, Alibaba cloud does not provide a C + + sdk. There is a C sdk. It is estimated that it can also be used to pound drums and drums, but I am not. I want to directly use the qmqtt library. In fact, the agreements are the same. Alibaba cloud has only slightly changed them. Do it when you decide! Go, Picasso!

Install a qmqtt library first. The front-end time installed a QSciscintilla control, at that time directly on the command line, Pa Pa Pa Pa Pa Pa Pa ~ not happy! It's still fresh in my memory. I didn't find a tutorial on the Internet at the beginning. I'm going to compile it on the command line. Here is the process (recall version, it has been two days, O(∩∩) O haha ~):

1. Download this library first

Yes! The following is the connection of github (copied to the browser and downloaded directly), which was found by wandering around the Internet. I saw where the github link had forgotten for the first time. Two links are also recommended on this blog: https://blog.csdn.net/yimuta9538/article/details/103885510 . No gossip, download it!


2. Look at the structure

It's probably like this, but I've compiled this one, so it's different from just downloading it. Let's explore all aspects first.

3. Compile with command line

Command line compilation is really cool, because I had a detailed understanding of QT compilation process some time ago, so I was a little complacent. I started the cmd command window in the qmqtt master folder. I won't put the compilation screenshot up. It takes up too much space. I used the following command:



mingw32-make install

This is the release compilation, and a debug compilation (because qmake is in release mode by default). Continue with the following command:

qmake CONFIG+=debug


mingw32-make install

Now that the compilation is finished, I'll think about how to use it.

4. Preparing files for qmqtt Library

This really took a lot of effort! This is the main reason to write this blog! Please watch it carefully. I used to refer to this blog: https://blog.csdn.net/qq_28877125/article/details/78357510?locationnum=6&fps=1 . Later, I found that I couldn't do it, so I had to explore and modify the document myself.

First of all, we need to collect the compiled library files and put them into two folders, i.e. the folder I need to call qmqtt (which is my own spare folder). If there is no problem in command execution (the problem is that the tool is not installed, the environment variables are set correctly, and Baidu is easy to solve), please create two new folders "include" and "lib", and then put the compiled files in it (be sure to pay attention! The files in my figure are not the same as those of others, because I use QT5.9.8). For details, I will give you a screenshot:

*1. * * this is all header files in the include folder. The source of these header files is XXX \ qmqtt master \ SRC \ mqtt. In the qmqtt folder is the qtqmqttdends. The source of the qmqtt folder is XXX \ qmqtt master \ include.



*2. * * this is in the Lib folder. The four library files generated by compilation are from XXX \ qmqtt master \ lib. Here, please note that according to the results of your own compilation, do not copy my file name. The name will vary according to the version, but there are only two. a and two. dll files in total. You can copy them.

*3. * * after finishing these two folders, copy them to the root directory of your qt project.

5. Call qmqtt Library

Here I take some detours, don't explain, just copy the project file and header file, and comment.

*1. * first of all, engineering documents

QT       += core gui network  #network must be added here!!!

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets


# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++11

        main.cpp \

        mainwindow.h \

FORMS += \

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -lQt5Qmqtt   #Notice the last name here. It's the same as the name of the library you compiled! (in the lib folder)
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -lQt5Qmqttd#Notice the last name here. It's the same as the name of the library you compiled! (in the lib folder)

INCLUDEPATH += $$PWD/include  #Copy it to add path
DEPENDPATH += $$PWD/include   #Copy it to add path

#The following judgment should pay attention to the last name, just like the name of the library you compiled! (in the lib folder)
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/lib/libQt5Qmqtt.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/lib/libQt5Qmqttd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/lib/Qt5Qmqtt.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/lib/Qt5Qmqttd.lib

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

*2. * * the following is the call in the. cpp file

Add the following reference to the header file.

#include "qmqtt.h"

Look at the figure, call all normal, installation succeeded!

~ ~ end and scatter flowers~~~~

Published 14 original articles, won praise 9, visitors 2128
Private letter follow

Tags: Qt github SDK network

Posted on Thu, 16 Jan 2020 10:00:44 -0500 by adzie