I have nearly 200 projects in Visual Studio and it takes too long to build them all. I notice that building stdafx.cpp (the precompiled headers) for each project is slow. I'm using the same header for every project, so why do I have to build it ~200 times? How can I build it once and share between projects?
-
5PLEASE VOTE FOR THIS: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/4931119-allow-precompiled-headers-to-be-shared-between-pro – Scott Langham Nov 08 '13 at 09:27
1 Answers
This question has been asked before, but Visual Studio has changed.
In Visual Studio 2008, it's possible to share the precompiled header with some hackery. Designate one project to build the PCH, and have every other project depend upon it (Project Dependencies). Ensure that you have only one stdafx.h and that every project can see it with #include "stdafx.h" (Additional Include Directories). Set every client project to use the masters PCH file (Precompiled Header File). Now use xcopy to copy the master's .pdb and .idb into each client output directory. You'll have to set the master project to output a pdb with a different name (Output Files). See links above for more specifics.
In Visual Studio 2010 and Visual Studio 2012 there's no known way to share PCH files.
-
2Others, including myself, were able to get this working in Visual Studio 2010 and 2012 (see the second link in David's answer: http://stackoverflow.com/questions/645747/sharing-precompiled-headers-between-projects-in-visual-studio/4170902#4170902). – Brad W Nov 16 '15 at 21:15