In visual studio 2010, I get
Error 1 error LNK2019: unresolved external symbol “public: __thiscall
Server::Server(class boost::asio::io_service &)”
(??0Server@@QAE@AAVio_service@asio@boost@@@Z) referenced in the
function _main C:\Users\Lucie\Documents\Visual Studio
2010\Projects\Expérimentation Serveur\Expérimentation
Serveur\Main_Serveur.obj
However, I have the class definition in the header file and the class implementation in the .cpp file both included in the solution, so I really don’t see why I’m getting this. Furthermore, I have checked, and the definition and declaration seem to match.
Here is Main_Serveur.cpp:
include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <hash_map>
#include <functional>
#include <boost/bind.hpp>
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/asio.hpp>
#include <hash_set>
#include "Connection.h"
#include "Server.h"
using boost::asio::ip::tcp;
int main()
{
try
{
boost::asio::io_service io_service;
Server server(io_service);
io_service.run();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}
std::cin.get();
return 0;
}
Here is Server.h:
#ifndef __SERVER_H__
#define __SERVER_H__
#include"Connection.h"
#include<boost\bind.hpp>
#include<boost\asio.hpp>
#include<boost\shared_ptr.hpp>
#include<boost\enable_shared_from_this.hpp>
#include<hash_set>
#include<string>
using boost::asio::ip::tcp;
class Connection;
class Server : public boost::enable_shared_from_this<Server>
{
public:
Server(boost::asio::io_service & io_service);
void removeSocketFromList(tcp::socket * socketToRemove);
void sendToList(std::string message);
void addSocketToList(tcp::socket * newSocket);
private:
void start_accept();
void handle_accept
(
boost::shared_ptr<Connection> new_connection,
const boost::system::error_code& error
);
std::hash_set<tcp::socket*> sockets_;
tcp::acceptor acceptor_;
};
#endif
And here is the relevant part of Server.cpp:
#include"Server.h"
#include"Connection.h"
#include<boost\asio.hpp>
#include<hash_set>
using boost::asio::ip::tcp;
Server::Server(boost::asio::io_service & io_service):
acceptor_(io_service, tcp::endpoint(tcp::v4(), 13))
{
start_accept();
}
Any help would be greatly appreciated.
Ended up creating a new project and including the sources and headers, and the project compiled.
Oh well.