aladin8848 aladin8848 - 1 month ago 12
C++ Question

Throwing error when trying to create a new instance of an webserver object in Visual Studio 2013

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

Answer

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.