3
votes

In my class I am trying to create a new instance of my webserver object:

.h

class Stub : public QObject
{
    Q_OBJECT

public:
    Stub(QObject *parent = 0);
    ~Stub();    

private:
    WebSocketServer *m_webSocketServer;

.cpp

Stub::Stub(QObject *parent)
    : QObject(parent)
{
    //Start Websocket-Server
    m_webSocketServer = new WebSocketServer(8000, true,this);   
}

My server constructor looks like:

explicit WebSocketServer(quint16 port, bool v = true, QObject *parent = Q_NULLPTR);

but it throws errors like this:

Error 7 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall WebSocketServer::~WebSocketServer(void)" (__imp_??1WebSocketServer@@UAE@XZ) referenced in function "public: virtual void * __thiscall WebSocketServer::`scalar deleting destructor'(unsigned int)" (??

Error 10 error LNK2001: unresolved external symbol "public: virtual void * __thiscall WebSocketServer::qt_metacast(char const *)" (?qt_metacast@WebSocketServer@@UAEPAXPBD@Z)

Error 8 error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall WebSocketServer::metaObject(void)const " (?metaObject@WebSocketServer@@UBEPBUQMetaObject@@XZ)

Error 9 error LNK2001: unresolved external symbol "public: virtual int __thiscall WebSocketServer::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@WebSocketServer@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

my webserver is working, just when creating instance of that it crashes. I tried adding libraries, included .h files, all names match

1
It does not crash. It gets linker errors. Seems like you declared the destructor but did not implement itHayt
That's a very peculiar definition of "working". I don't think my manager would buy it.molbdnilo
@molbdnilo just wanted to tell you, I think its not important to show code of that. its actualy a library that I importedDušan Tichý
@DušanTichý I suspect that you forgot to link with that library.molbdnilo

1 Answers

1
votes

I got it:

What I had to do:

  1. Checked again if I added libraries and I noticed I put it to wrong place

Project -> Properties -> Configuration Properties -> Linker -> General -> Additional dependencies

but It was supposed to be inside this:

Project -> Properties -> Configuration Properties -> Linker -> Input-> Additional dependencies

  1. Even when I added it correctly, I got error with missing .dll file, so what I've done is I put missing .dll copy into output directory (Project -> Properties -> Configuration Properties -> General-> Output Directory)

Now it works as I intened.

Thanks all for effort.