I am using C++ with Visual Studio 2010. I am trying to build a client-server architecture where both client and server rely on the same 'Engine'
Following is a diagram which explains this:
image http://img266.imageshack.us/img266/5573/dependencies.png
Where:
Engine - Application specific engine
BaseEngine - Non-application specific engine (used by other applications)
SomeLibrary - A library that the BaseEngine depends on
Using Visual Studio, I have set up the appropriate project references and 'Include Directories'.
The Client is able to see methods in the Engine and the Engine is able to see methods in the the BaseEngine. However the problem is that I'm getting a few Link errors (LNK1120, LNK2001) when the Client and/or Server call methods on the Engine.
It seems that this is occuring because the Engine relies on BaseEngine and the Client does not have a dependency on BaseEngine.
So my question is:
Is there anyway that the Engine and BaseEngine projects can be wrapped up so that the Client and Server don't need to reference the BaseEngine?
The question is: Are the linker errors related to Engine.lib or to BaseEngine.lib?
I assume you have problems with functions exported by BaseEngine.lib and referenced in client/server which result in unresolved symbols.
If your client/server rely on functionality exported by BaseEngine.lib but you only refrence Engine.lib you have to either reference BaseEngine library directly or make Engine.lib forward these functionality provided by BaseEngine.lib explicitly.
The fact that Engine.lib does depend on (and reference) BaseEngine.lib does not imply that the functionality of BaseEngine.lib is seamless forwarded by Engine.lib. I guess you are stumbling across this assumption. The linker just includes functionality from BaseEngine.lib to Engine.lib if they are really needed. But none of this functionality is visible to further dependencies (client/server in your case) until you explicitly do so. I would suggest you write some kind of wrapper functionality in Engine.lib to forward functions from BaseEngine.lib referenced by client/server.