Solved QtWebsocket mainwindow example
-
I've recently explored the Non SSL Console version of the QtWebsocket server examples and as such I'm wondering about the approach to using the QtWebsocket server in a mainwindow application.
This section of the Console version main.cpp
bool debug = parser.isSet(dbgOption);
int port = parser.value(portOption).toInt();
EchoServer *server = new EchoServer(port, debug);
QObject::connect(server, &EchoServer::closed, &a, &QCoreApplication::quit);I've tried unsuccessfully with mainwindow.cpp
--within a ui(new Ui::MainWindow) statement:
bool debug = false;
quint16 port = 11192;
server = new EchoServer(port,debug);
QObject::connect(server, &EchoServer::closed, this, &QCoreApplication::quit);fails with LINK Errors:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall EchoServer::EchoServer(unsigned short,bool,class QObject *)" (??0EchoServer@@QAE@G_NPAVQObject@@@Z) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall EchoServer::closed(void)" (?closed@EchoServer@@QAEXXZ) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)
-
This indicates that EchoServer.cpp is not compiled or some build issue. I suggest you to clean(if possible remove) the build directory. Rebuild your application. It should work.
-
Thanks for your suggestion. Earlier I had 'Cleaned All' without success. Using your suggestion: stripped out all the obj files manually and build the 'target' cpp separately which led to the project building successfully.