3

Consider visual studio solution with multiple projects, some source files are used in several projects. I'm currently including source files used in multiple projects in each project, but that leads to same source file being compiled for each project. Is there any way to specify single project to be a one that builds files, and link against built objects in all the other projects.

I'm aware of option to create a static lib, but I would like to know if it is possible to specify dependencies directly between the projects in solution - like you can do by writing makefile.

Search has revealed single question on the subject from 2010, but there is no suitable solution there: How to use the same obj files in different projects in the same solution

Community
  • 1
  • 1
Ilya Kobelevskiy
  • 5,245
  • 4
  • 24
  • 41

3 Answers3

0

You can specify project dependencies (http://msdn.microsoft.com/en-us/library/et61xzb3(v=vs.80).aspx) but in order to use the same source between the projects you'll need to create a static lib or a dll and link with that. You can set up these configurations in the project settings as well so you won't have code that shows the linking, it's all done in compile/linking statements

sedavidw
  • 11,116
  • 13
  • 61
  • 95
0

One thing you might consider is to create a solution where you have multiple projects, and you properly set the building dependency of each your projects such that the 'base project' will always built before other projects depending it it are built.

S. J
  • 86
  • 6
0

as you mention Static lib is the best project type to do that. group all your common file in a static lib project, and on your DLL or exe project create a dependency to the lib by using the "add dependency" option you should get with a right click on your project in the VS solution explorer pane.

take care about 1 thing : if you create a cascade of dependency between Libs they will become bigger and bigger (the last lib of the chain will contain all the symbol of all the other ... a kind of cat of the .obj file....)

alexbuisson
  • 7,699
  • 3
  • 31
  • 44