I happened to get that already defined in .obj error. This is structure of my project:
main.cpp
#include "main.h";
main.h
#include <iostream>
#include <string>
#include <sstream>
#include <boost/asio.hpp>
#include <boost/thread/thread.hpp>
#include "client.cpp"
client.cpp
#ifndef SOCKET_CLIENT_CLASS
#define SOCKET_CLIENT_CLASS
#ifndef BOOST_ASIO_HPP
#include <boost/asio.hpp>
#endif
/*CLASS DEFINITION HERE*/
#endif
This is what compiler is complaining about:
main.obj : error LNK2005: "public: bool __thiscall SocketClient::read(int,char *)" (?read@SocketClient@@QAE_NHPAD@Z) already defined in client.obj
Note it is complaining about my class, not boost. One interesting thing is, that when I remove #include <boost/asio.hpp>
from client.cpp, I get errors thouhg it is included in main.h too.
As you can see, I'm not double defining/including my class, its included exactly once in main.h. So what's going on here?
I have read this answer, but it was no help, since it expects double inclusions. Take this fact into osideration before voting for duplicate, because this simply means beheading me without mercy.