emqx / qmqtt

MQTT client for Qt

Home Page:https://www.emqx.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation error with QT_NO_SSL defined

gfleck opened this issue · comments

I'm trying to compile with QT_NO_SSL defined on my qtnetwork-config.h but an error occurs.

My qtnetwork-config.h is like this:

#define QT_FEATURE_networkinterface 1
#define QT_FEATURE_bearermanagement 1
#define QT_FEATURE_dnslookup 1
#define QT_FEATURE_dtls 1
#define QT_FEATURE_ftp 1
#define QT_FEATURE_http 1
#define QT_FEATURE_localserver 1
#define QT_FEATURE_networkdiskcache 1
#define QT_FEATURE_networkproxy 1
#define QT_FEATURE_opensslv11 -1
#define QT_FEATURE_sctp -1
#define QT_NO_SCTP 
#define QT_FEATURE_socks5 1
#define QT_FEATURE_ssl 1
#define QT_FEATURE_udpsocket 1
#define QT_NO_SSL

The compilation error is:

In file included from /home/gfleck/qt/qt5.12.3/5.12.3/gcc_64/include/QtNetwork/QtNetwork:12:0,
from ../../include/QtQmqtt/QtQmqttDepends:4:
/home/gfleck/qt/qt5.12.3/5.12.3/gcc_64/include/QtNetwork/qdtls.h:128:20: error: ‘QSslSocket’ has not been declared
explicit QDtls(QSslSocket::SslMode mode, QObject *parent = nullptr);
^~~~~~~~~~
/home/gfleck/qt/qt5.12.3/5.12.3/gcc_64/include/QtNetwork/qdtls.h:128:40: error: expected ‘)’ before ‘mode’
explicit QDtls(QSslSocket::SslMode mode, QObject *parent = nullptr);
^~~~
/home/gfleck/qt/qt5.12.3/5.12.3/gcc_64/include/QtNetwork/qdtls.h:137:5: error: ‘QSslSocket’ does not name a type; did you mean ‘QUdpSocket’?
QSslSocket::SslMode sslMode() const;
^~~~~~~~~~
QUdpSocket

Does anyone have any idea what it might be?

Thanks.

commented

Hi @ejvr,

I am not using any other module, I'm using the source code of this repository.

The target name is QtQmqtt and you can check it here: https://github.com/emqx/qmqtt/blob/master/src/mqtt/qmqtt.pro#L1

/home/gfleck/qt/qt5.12.3/5.12.3/gcc_64/include/QtNetwork/qdtls.h:

But this is not a header of our library, so no idea how this one gets included when SSL has been disabled 🤔 .

Hi @mwallnoefer

qdtls.h is a qt standard library.

commented

@gfleck You're completely right. I'm used to using cmake instead of qmake, so I was unaware of the QtQmqtt header. It is generated by qmake build process. That header includes QtQmqtt/QtQmqttDepends which in turn includes QNetwork/QNetwork which is part of QT. This one includes many other QT headers within the QNetwork module. Some of them are SSL related like qsslconfiguration.h, but there are not surrounded by any check on QT_NO_SSL.

I know that some SSL related headers should not be included if SSL is disabled, and apparently qdtls.h is one of them.

Anyway, this header is outside out control. We can't change the dependencies in qmqtt.pro either to get rid of the include in QtQmqttDepends, because it would break the build.

In short, the only solution I can see, it to replace the QtQmqtt include with a include of qmqtt.h. This will include all QMQTT classes you need, and it honours QT_NO_SSL.