Reputation: 805
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?
Upvotes: 3
Views: 284
Reputation: 710
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...
Upvotes: 1
Reputation: 7773
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!
Upvotes: 1
Reputation: 14619
Is there a way such that B does not have to include the Boost library as well?
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
).
Upvotes: 2