How to use the same obj files in different projects in the same solution
I have a solution that contains several projects. Som开发者_开发百科e of these projects share source files. I have set up my project tree so that the projects that share source files are together. My problem is that when I do a clean and build the shared source files get re-compiled for every project, not just the first one that uses them. The result is that the initial build takes longer than it should and I have to build more than once to get all of the dependencies satisfied (re-links are necessary.) The project is a port from a gcc project that uses a series of make files to perform the build. The make files do not repeat the compiles. Is there any way to handle the above situation so that the dependencies are satisfied in Visual Studio as one would expect? Is the problem due to a dependency between the source file and the .idb and .pdb files?
Update: What I really need is a way to tell VS to perform a re-link on the same obj files with different DLL and LIB names. I can get this to work by including .obj files in the re-link projects but haven't been able to figure out how to create debug/release versions. In the sections of the project files the $(IntDir) does not seem to get parsed. So...
In project1
file1.c file2.c file3.c link into dll1.dll,dll1.lib
then in project 2 the object files from the project1 get linked again only this time into dll2.dll,dll2.lib
project3 same thing. etc.
I posted this on an MS forum also and as yet have not received an answer.
If you can reorganise the code to do this, build the shared .obj files into a library project, then you can link with that library from the dependent projects.
That's the only "clean" way I can think of to solve the problem - anything else I can think of is likely to involve "fighting" or "tricking" visual studio, which is usually a bad idea.
精彩评论