emqx / qmqtt

MQTT client for Qt

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

throw an error "QMQTT has not been declared" when build the .obj/moc_qmqtt_ssl_socket_p.o

wanghaEMQ opened this issue · comments

The command and the error are as below:

arm-linux-gnueabihf-g++-4.8 -c -include .pch/Qt5Qmqtt -pipe -O2 -march=armv7-a -O2 -march=armv7-a -O2 -std=c++11 -fvisibility=hidden -fvisibility-inlin    es-hidden -fno-exceptions -Wall -W -Wvla -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQT_NO_CAST_TO_ASCII -DQT_NO_    CAST_FROM_ASCII -DQT_BUILD_QMQTT_LIB -DQT_BUILDING_QT -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DI    SABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_C    ORE_LIB -I. -I. -I../../include -I../../include/QtQmqtt -I/usr/local/src/qmqtt-master/include/QtQmqtt/1.0.0 -I/usr/local/src/qmqtt-master/include/QtQmq    tt/1.0.0/QtQmqtt -I/opt/qt5.7.0/include -I/opt/qt5.7.0/include/QtWebSockets -I/opt/qt5.7.0/include/QtNetwork -I/opt/qt5.7.0/include/QtCore -I.moc -I/op    t/tslib/include -I/opt/qt5.7.0/mkspecs/linux-arm-gnueabihf-g++ -o .obj/moc_qmqtt_ssl_socket_p.o .moc/moc_qmqtt_ssl_socket_p.cpp
 .moc/moc_qmqtt_ssl_socket_p.cpp:55:6: error: ‘QMQTT’ has not been declared
void QMQTT::SslSocket::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
          ^
.moc/moc_qmqtt_ssl_socket_p.cpp:63:19: error: ‘QMQTT’ has not been declared
const QMetaObject QMQTT::SslSocket::staticMetaObject = {
                                         ^
.moc/moc_qmqtt_ssl_socket_p.cpp:64:8: error: ‘SocketInterface’ has not been declared
   { &SocketInterface::staticMetaObject, qt_meta_stringdata_QMQTT__SslSocket.data,
...

I think you should post the generated .moc/moc_qmqtt_ssl_socket_p.cpp file.

I have missed that: you claim that PR #204 also fixes this one? I am a bit puzzled but maybe you could provide us with a compelling reason why you think so...
(don't get me wrong: PR #204 is fine, I have merged it before).

I am so sorry, the reason I added this issue is for the convenience of those who also have this error.

.moc/moc_qmqtt_ssl_socket_p.cpp

/****************************************************************************
** Meta object code from reading C++ file 'qmqtt_ssl_socket_p.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.7.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#include "../qmqtt_ssl_socket_p.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'qmqtt_ssl_socket_p.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.7.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif

QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_QMQTT__SslSocket_t {
    QByteArrayData data[1];
    char stringdata0[17];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
    qptrdiff(offsetof(qt_meta_stringdata_QMQTT__SslSocket_t, stringdata0) + ofs \
        - idx * sizeof(QByteArrayData)) \
    )
static const qt_meta_stringdata_QMQTT__SslSocket_t qt_meta_stringdata_QMQTT__SslSocket = {
    {
QT_MOC_LITERAL(0, 0, 16) // "QMQTT::SslSocket"

    },
    "QMQTT::SslSocket"
};
#undef QT_MOC_LITERAL

static const uint qt_meta_data_QMQTT__SslSocket[] = {

 // content:
       7,       // revision
       0,       // classname
       0,    0, // classinfo
       0,    0, // methods
       0,    0, // properties
       0,    0, // enums/sets
       0,    0, // constructors
       0,       // flags
       0,       // signalCount

       0        // eod
};

void QMQTT::SslSocket::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    Q_UNUSED(_o);
    Q_UNUSED(_id);
    Q_UNUSED(_c);
    Q_UNUSED(_a);
}

const QMetaObject QMQTT::SslSocket::staticMetaObject = {
    { &SocketInterface::staticMetaObject, qt_meta_stringdata_QMQTT__SslSocket.data,
      qt_meta_data_QMQTT__SslSocket,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};


const QMetaObject *QMQTT::SslSocket::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}

void *QMQTT::SslSocket::qt_metacast(const char *_clname)
{
    if (!_clname) return Q_NULLPTR;
    if (!strcmp(_clname, qt_meta_stringdata_QMQTT__SslSocket.stringdata0))
        return static_cast<void*>(const_cast< SslSocket*>(this));
    return SocketInterface::qt_metacast(_clname);
}

int QMQTT::SslSocket::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = SocketInterface::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    return _id;
}
QT_END_MOC_NAMESPACE

I have compared the file contents with the version generated by Qt 5.9 moc on my PC and the differences are negligible. So it should be OK.

When I am looking at the build output I see that you are using a really ancient compiler which was NOT even 100% C++11-compliant: arm-linux-gnueabihf-g++-4.8 = GCC 4.8 for ARMv7 as cross compiler.
So I warmly encourage you to update GCC to at least release 4.9.3 which has demonstrated its reliability for ARMv7 under many environments not limited to Android, but also for embedded devices on the base of Yocto.

@ejvr or @KonstantinRitt: Would you like to add something here?