emqx / qmqtt

MQTT client for Qt
https://www.emqx.com
Other
692 stars 337 forks source link

Using pri file #242

Closed huseyinkozan closed 2 years ago

huseyinkozan commented 2 years ago

Hi, I created a console app and tried to include pri file like;

# QMQTT
QT     += websockets
CONFIG += QMQTT_WEBSOCKETS
CONFIG += NO_UNIT_TESTS
DEFINES += QT_WEBSOCKETS_LIB
include($$PWD/../thirdparty/qmqtt-1.0.1/qmqtt.pri)

But I got below errors. How can I use pri file ?

11:15:30: Starting: "/usr/bin/make" -j4
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_client.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_client_p.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_frame.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_message.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_network.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_router.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_routesubscription.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_socket.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_timer.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_ssl_socket.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_websocket.cpp
compiling ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_websocketiodevice.cpp
compiling ../app/main.cpp
generating ./moc_predefs.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_client.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_network_p.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_networkinterface.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_router.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_routesubscription.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_socket_p.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_socketinterface.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_timer_p.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_timerinterface.h
moc ../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_ssl_socket_p.h
compiling moc_qmqtt_client.cpp
compiling moc_qmqtt_network_p.cpp
compiling moc_qmqtt_networkinterface.cpp
compiling moc_qmqtt_router.cpp
compiling moc_qmqtt_routesubscription.cpp
compiling moc_qmqtt_socket_p.cpp
compiling moc_qmqtt_socketinterface.cpp
compiling moc_qmqtt_timer_p.cpp
compiling moc_qmqtt_timerinterface.cpp
compiling moc_qmqtt_ssl_socket_p.cpp
linking app
/usr/bin/ld: qmqtt_websocket.o: in function `QMQTT::WebSocket::WebSocket(QString const&, QWebSocketProtocol::Version, QSslConfiguration const*, QObject*)':
/tmp/qmqtt-test/build-app-Desktop_Qt_5_12_11_GCC_64bit-Debug/../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_websocket.cpp:16: undefined reference to `vtable for QMQTT::WebSocket'
/usr/bin/ld: qmqtt_websocket.o: in function `QMQTT::WebSocket::WebSocket(QString const&, QWebSocketProtocol::Version, QObject*)':
/tmp/qmqtt-test/build-app-Desktop_Qt_5_12_11_GCC_64bit-Debug/../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_websocket.cpp:30: undefined reference to `vtable for QMQTT::WebSocket'
/usr/bin/ld: qmqtt_websocketiodevice.o: in function `QMQTT::WebSocketIODevice::WebSocketIODevice(QWebSocket*, QObject*)':
/tmp/qmqtt-test/build-app-Desktop_Qt_5_12_11_GCC_64bit-Debug/../thirdparty/qmqtt-1.0.1/src/mqtt/qmqtt_websocketiodevice.cpp:9: undefined reference to `vtable for QMQTT::WebSocketIODevice'
coll
ect2: error: ld returned 1 exit status
make: *** [Makefile:311: app] Error 1
11:15:44: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project app (kit: Desktop Qt 5.12.11 GCC 64bit)
When executing step "Make"

qmqtt-test.zip

huseyinkozan commented 2 years ago

Note; I have added some destructors to suppress warnings/errors

mwallnoefer commented 2 years ago

@ejvr any idea? Could it be that moc isn't run on the websocket's code?

ejvr commented 2 years ago

Yep, looks like you're right. It appears that the websocket headers are not passed to qmake.

@huseyinkozan In the file qmqtt.pri in the root of the repo, can you change PRIVATE_HEADERS to HEADERS (line 55). That would force the moc to process the websocker headers.

huseyinkozan commented 2 years ago

@ejvr Thanks. It builds now

mwallnoefer commented 2 years ago

Yep, looks like you're right. It appears that the websocket headers are not passed to qmake.

@huseyinkozan In the file qmqtt.pri in the root of the repo, can you change PRIVATE_HEADERS to HEADERS (line 55). That would force the moc to process the websocker headers.

@ejvr But usually this should be working, so we shall not modify our qmqtt.pri file? I am just asking if we should close the bug or deliver this change.

ejvr commented 2 years ago

That's the plan, I hope I can find some time thing week to create a pull request.

Got to recreate my build env first...