Skip to main content
GameDev.net gamedev.net
🔒 Locked

project dependencies in visual studio

Started by Structure Mar 26, 2005 at 4:32 AM 3 replies 1k views
Original Post
Structure
Structure
Hi, Ive separated my engine out into separate projects in one visual studio solution, to make it a bit more modular, but I have a few files such as global defines that are needed in all of the lib’s, at the moment ive just put them in one of the projects, but this creates circular dependencies, something that im trying to avoid. Whats the best things to do? Create another projects lib with these files in? or is there some other cunning plan out there?
[happy coding]
Erzengeldeslichtes
Erzengeldeslichtes
Global defines as in macros? If so, then they must be in header files and need to be included in all of the projects. Same with global constants, and function prototypes. The only thing that goes into a lib is an implementation.

What you do is you make a seperate folder with your header files that all libs need, and add that folder to their additional include path. Then you simply include as you normally do. Once you make a change to the header file, all the projects will need to be opened and compiled, but you won't have to do any copying, etc.
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?
Structure
Structure
Mm ok I see what you saying, ive never worked with libs before, ive just always had one large project so you’ll have to bear with me.:)

Lets say I have 3 projects Main, Physics, Render,

Main builds the exe, and physics and render build libs

To compile I include the physics and render libs into main,

Now lets say I have a fixed point math class that needs to be included in all of the projects, this has a .h and .cpp file so needs to be compiled, where would be the correct place to put this? At the moment its in the physics lib, but render and main need to use it, this creates a circle with physics and main.

I was thinking of creating another lib for global stuff and putting it in there, this way theres only one way flow, but this seems a bit odd, so I was trying to find the correct thing to do?
[happy coding]
Koen
Koen
Adding another lib is the right thing to do. It's perfectly ok for libs to be dependent of other libs. I think it's better to avoid two libs being dependent of eachother, though. But maybe that's just personal preference :)
Erzengeldeslichtes
Erzengeldeslichtes
Quote:
Original post by Structure
Now lets say I have a fixed point math class that needs to be included in all of the projects, this has a .h and .cpp file so needs to be compiled, where would be the correct place to put this? At the moment its in the physics lib, but render and main need to use it, this creates a circle with physics and main.

Make it a seperate lib, in a seperate folder. Then each of those three has that math lib in its include path and additional dependancies. You also might want to seperate it out into "math\lib" for the lib, "math\include" for the header files, and "math\source" for the source files. This way you can include "math\include" in the additional include folders, and "math\lib\math.lib" in the additonal dependancies.
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.