user1205407
user1205407

Reputation: 11

Visual Studio 2010: Working with multiple C++ projects

I am working on a game engine project in C++ with VS2010. We have one main project, OgreProject, which includes some Ogre3D stuff for rendering. Then, we have a class library project called AudioLibrary. AudioLibrary uses fmod, and has includes to the appropriate headers and libs. The problem arises when a class in OgreProject wants to use the SoundPlayer.h in AudioLibrary. Then, OgreProject does not know where #include is. It feels wrong to tell OgreProject where fmod is, since it will not directly use these headers. What is the correct way to using header files from AudioLibrary in OgreProject, without OgreProject knowing of ?

Upvotes: 1

Views: 545

Answers (3)

Swapnil
Swapnil

Reputation: 437

You should probably define a heirarchy for all the components of your project and keep all the header files from a particular component which other components are going to use at a pre-defined place. Other components can then always look at this place. There is nothing wrong in telling the components where to look for these dependencies explicitly

Upvotes: 0

Ben Voigt
Ben Voigt

Reputation: 283793

You might try the Pimpl idiom (or pattern).

It will let you remove everything related to fmod from your project's header file. Only the implementation files will need the fmod headers, not client projects.

See this answer which explains the benefits.

Upvotes: 0

Billy ONeal
Billy ONeal

Reputation: 106609

There is no correct way. There's no magical way for one library to know about the other library; you'd have to configure them to do that. If you put them in the same solution you can add one project to another as a project reference.

Upvotes: 1

Related Questions