Reputation: 2427
I'm trying to setup a C++ solution that has multiple projects, for simplicity I'll call them ProjectA
and ProjectB
.
ProjectB
is setup as a Static Library and uses an external library, I'll call it ExternalLib
, that's been added to the Additional Includes in the properties of ProjectB
. ProjectA
has ProjectB
added as a reference and has been added to the Additional Includes section of ProjectA
. So far so good, I can reference classes in ProjectB
from ProjectA
but when I go to compile I get an error that one of the headers from ExternalLib
can't be found. Not sure how to proceed I added ExternalLib
to the Additional Includes section of ProjectA
and built again. Now I get unresolved externals for classes in ExternalLib
.
I'm sure I could fix the unresolved externals by adding ExternalLib
to the Additional Dependencies for the Linker of PorjectA
. However, I'm confused as to whether that's the right way to handle this. I'm a little new to C++ projects in VS, I'm more familiar with C#, so my question is:
Is it standard to have to include a referenced project's (ProjectB
) dependencies (ExternalLib
) in my main project (ProjectA
)? Or have I configured PorjectB
incorrectly?
Upvotes: 0
Views: 365
Reputation: 15164
Check your ProjectB header files, if header files included by ProjectA reference anything from ExternalLib then ProjectA will need to be told about ExternalLib. Usually I find the problem is that ProjectB is only supposed to use ExternalLib internally but that some part of ExternalLib has snuck into the public face of ProjectB. If something from ExternalLib is indeed supposed to be part of the public face of ProjectB then yes, anything that uses ProjectB will also need to be told about ExternalLib (ProjectB's knowledge of ExternalLib is not inherited by projects that reference ProjectB).
Upvotes: 2