Take the 2-minute tour ×

So I have two projects, A and B, where B is dependent on A (A is a library, while B is a console application). A uses the boost library, and has been configured to include the header and library files, but B has not.

Visual studio throws an error saying the Boost Header files cannot be found (in project B). For example:

error C1083: Cannot open include file: 'boost/asio.hpp': No Such file or directory [Project: B]

My question is: Is there a way such that B does not have to include the Boost library as well?

share|improve this question

3 Answers 3

up vote 2 down vote accepted


Yes, but only if you can avoid using the features as part of A's type/function definitions. If they can be used truly implementation-only, then you can avoid the header dependency -- you'll still need to link against compiled libraries (asio requires boost-system).

share|improve this answer
The classes have boost objects, (private: boost::asio::io_service service), so this means that it's impossible to separate the include of boost headers, which means B has to include both headers and compiled libraries, right? –  Mike Nov 12 '12 at 5:04
You are correct. –  Brian Cain Nov 12 '12 at 5:06
Oh well. Thanks anyway! –  Mike Nov 12 '12 at 5:08

The problem arises if you include a .h from project A that includes itself a boost header. If you only include your boost hpp from the cpp files of project A and you keep a "boost-less" interface to your library, you should be fine!

share|improve this answer

If A is a nice library, it should only expose an interface(s) and a factory, that is abstract classes defined in a header that is bare and does not include other headers. Sounds like this is not the case, but it is usually possible to bring any library to this state. Worst case is that you'll have to build a wrapper-like de-coupling layer. Another option is to set up your project B to include boost. You may still need it for your own use...

share|improve this answer
I'll try designing A the way you described, thanks for the advice. –  Mike Nov 12 '12 at 5:13

Your Answer


