Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. VS2013 with QT5.3.2 using QWebsocket and got a unresolved external symbol issue

VS2013 with QT5.3.2 using QWebsocket and got a unresolved external symbol issue

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 852 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mapleelyse
    wrote on last edited by
    #1

    I got a problem with VS2013 and QT5.3.2. when I am using Websocket, it says unresolved external symbol with QWebSocket::sendTextMessage and other websocket functions.

    I have already #include <QtWebSockets/QWebSocket> and set the QT Project Setting and checked WebKit and Network Module。

    and this is the full error message I have got :

    1>mainwindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QWebSocket::~QWebSocket(void)" (_imp??1QWebSocket@@UAE@XZ),referenced in function "public: virtual __thiscall MWebSocket::~MWebSocket(void)" (??1MWebSocket@@UAE@XZ) 1>MWebSocket.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QWebSocket::~QWebSocket(void)" (_imp??1QWebSocket@@UAE@XZ) 1>MWebSocket.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QWebSocket::QWebSocket(class QString const &,enum QWebSocketProtocol::Version,class QObject *)" (_imp??0QWebSocket@@QAE@ABVQString@@W4Version@QWebSocketProtocol@@PAVQObject@@@Z),referenced in function "public: __thiscall MWebSocket::MWebSocket(class QUrl const &,class QObject *)" (??0MWebSocket@@QAE@ABVQUrl@@PAVQObject@@@Z) 1>MWebSocket.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall QWebSocket::sendTextMessage(class QString const &)" (_imp?sendTextMessage@QWebSocket@@QAE_JABVQString@@@Z),referenced in function "private: void __thiscall MWebSocket::onConnected(void)" (?onConnected@MWebSocket@@AAEXXZ) 1>MWebSocket.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWebSocket::close(enum QWebSocketProtocol::CloseCode,class QString const &)" (_imp?close@QWebSocket@@QAEXW4CloseCode@QWebSocketProtocol@@ABVQString@@@Z),referenced in function "private: void __thiscall MWebSocket::onTextMessageReceived(class QString)" (?onTextMessageReceived@MWebSocket@@AAEXVQString@@@Z) 1>MWebSocket.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWebSocket::open(class QUrl const &)" (_imp?open@QWebSocket@@QAEXABVQUrl@@@Z),referenced in function "public: __thiscall MWebSocket::MWebSocket(class QUrl const &,class QObject *)" (??0MWebSocket@@QAE@ABVQUrl@@PAVQObject@@@Z) 1>MWebSocket.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWebSocket::connected(void)" (_imp?connected@QWebSocket@@QAEXXZ),referenced in function "public: __thiscall MWebSocket::MWebSocket(class QUrl const &,class QObject *)" (??0MWebSocket@@QAE@ABVQUrl@@PAVQObject@@@Z) 1>MWebSocket.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWebSocket::disconnected(void)" (_imp?disconnected@QWebSocket@@QAEXXZ),referenced in function "public: __thiscall MWebSocket::MWebSocket(class QUrl const &,class QObject *)" (??0MWebSocket@@QAE@ABVQUrl@@PAVQObject@@@Z) 1>MWebSocket.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWebSocket::textMessageReceived(class QString const &)" (_imp?textMessageReceived@QWebSocket@@QAEXABVQString@@@Z),referenced in function "private: void __thiscall MWebSocket::onConnected(void)" (?onConnected@MWebSocket@@AAEXXZ) 1>MWebSocket.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static struct QMetaObject const QWebSocket::staticMetaObject" (_imp?staticMetaObject@QWebSocket@@2UQMetaObject@@B) 1>debug/\MapleUI.exe : fatal error LNK1120: 9 unresolved externals

    this is the code for Websocket:

    @
    //HEADER
    #pragma once
    #include "global.h"

    class MWebSocket : public QObject
    {
    Q_OBJECT
    public:
    explicit MWebSocket(const QUrl &url, QObject *parent = Q_NULLPTR);

    Q_SIGNALS:
    void closed();

    private Q_SLOTS:
    void onConnected();
    void onTextMessageReceived(QString message);
    

    private:
    QWebSocket m_webSocket;
    QUrl m_url;
    };

    //CPP

    #include "global.h"
    #include "MWebSocket.h"

    QT_USE_NAMESPACE

    //! [constructor]
    MWebSocket::MWebSocket(const QUrl &url, QObject *parent) :
    QObject(parent),
    m_url(url)
    {
    connect(&m_webSocket, &QWebSocket::connected, this, &MWebSocket::onConnected);
    connect(&m_webSocket, &QWebSocket::disconnected, this, &MWebSocket::closed);
    m_webSocket.open(QUrl(url));
    }
    //! [constructor]

    //! [onConnected]
    void MWebSocket::onConnected()
    {
    qDebug() << "WebSocket connected";
    connect(&m_webSocket, &QWebSocket::textMessageReceived,
    this, &MWebSocket::onTextMessageReceived);
    m_webSocket.sendTextMessage(QStringLiteral("H2ello, world!"));
    }
    //! [onConnected]

    //! [onTextMessageReceived]
    void MWebSocket::onTextMessageReceived(QString message)
    {
    qDebug() << "Message received:" << message;
    m_webSocket.close();
    }
    //! [onTextMessageReceived]

    @
    anyone have idea about how to solve this problem? thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Maybe a silly question but did you add

      @QT += websockets@

      To your pro file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved