I am creating a DLL library which will export some functions to be used in other C++ projects. In my library, I am using precompiled headers, as well as Boost ASIO. However, I want to know if it is possible to contain all ASIO related things within the library itself so that the other program does not need to include them. For example:
stdafx.h (library):
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinSock2.h>
#include <iostream>
#include <string.h>
#pragma comment(lib, "ws2_32")
#include <boost/asio.hpp>
Client.h (library):
#pragma once
#ifdef LIB_EXPORTS
#define LIB_API __declspec(dllexport)
#else
#define LIB_API __declspec(dllimport)
#endif
using boost::asio::ip::tcp;
namespace TestLib {
class Client {
boost::asio::io_service io_service_;
tcp::resolver resolver_;
tcp::socket socket_;
public:
LIB_API Client();
LIB_API bool Connect(const std::string& szHost, const std::string& szPort);
virtual ~Client();
};
}
However, in my program that uses this library, I want to be able to include Client.h without also having to include Boost ASIO. Because I include this header without including Boost ASIO, I get errors about all of the lines in Client.h that reference Boost utilities, such as the using statement and the three private member variables.
How do I go about creating the library in such a way so that my other program only needs to include Client.h, for example?