views:

41

answers:

1

Hi,

I have an very strange error : When i want to use the SocialServer::Client class from my SocialServer::Server class the linker threw me 2 LNK2019 errors :

Error 1 error LNK2019: unresolved external symbol "public: void __thiscall SocialServer::Client::Handle(void)" (?Handle@Client@SocialServer@@QAEXXZ) referenced in function "private: static unsigned int __stdcall SocialServer::Server::listenThread(void *)" (?listenThread@Server@SocialServer@@CGIPAX@Z) C:\Users\benjamin\Documents\Visual Studio 2010\Projects\FCX Social Server\SocialServer Core\Server.obj SocialServer Core

Error 2 error LNK2019: unresolved external symbol "public: __thiscall SocialServer::Client::Client(unsigned int)" (??0Client@SocialServer@@QAE@I@Z) referenced in function "private: static unsigned int __stdcall SocialServer::Server::listenThread(void *)" (?listenThread@Server@SocialServer@@CGIPAX@Z) C:\Users\benjamin\Documents\Visual Studio 2010\Projects\FCX Social Server\SocialServer Core\Server.obj SocialServer Core

However , these 2 missing function are correctly implemented :

Client.h

#pragma once

#include "dll.h"

namespace SocialServer
{
    class __social_class Client
    {
    public:
        Client(SOCKET sock);
        ~Client();

        void Handle();

    private:
        static unsigned __stdcall clientThread(void* value);

        SOCKET _socket;
        uintptr_t _thread;
        unsigned int _thread_id;
    };
}

Client.cpp

#pragma once

#include "Client.h"

namespace SocialServer
{
 Client::Client(SOCKET socket)
 {
  this->_socket = socket;
 }

 Client::~Client()
 {
 }

 void Client::Handle()
 {
  std::cout << " New client " << std::endl;
  this->_thread = _beginthreadex(NULL, 0, Client::clientThread, &this->_socket, CREATE_SUSPENDED, &this->_thread_id);
  ResumeThread((HANDLE)this->_thread);
 }

 unsigned __stdcall Client::clientThread(void* value)
 { 
  // Some code to execute here ...
 }
}

Where does the problem comes from ?

A: 

Hi, i've found the solution. In a function that's used by _beginthreadex() (with unsigned __stdcall) , always add a return at the end.

Sywesk