tags:

views:

15

answers:

1

I have two projects within one solution. Both projects contain some files that are the same. For instance, Project1 contains shared.cpp and so does Project2. However, when I edit shared.cpp and build both projects, is there any way I can make VC++ compile the source file once, then use the single object file in the linking of the two projects, rather than compiling it twice? The obvious purpose being to decrease build time.

+1  A: 

Put shared.cpp in a separate project in the same solution and make it build as a library. Then add that project as a dependency to project1 and project2.

What's an elegant way to set up the two projects to link the static library?
kaykun
Never mind, project references seem to work very well for this purpose - http://msdn.microsoft.com/en-us/library/ms235627.aspx Thanks for mentioning a library; my original thoughts were totally off.
kaykun