2

How can the error "LNK4206 precompiled type information not found" be prevented in a solution with a shared precompiled header?

I try to configure a visual studio 2015 update 3 solution with all projects sharing the same precompiled header in an attempt to reduce build times. The precompiled header is in a separate project and constructs the .pch file and .lib file on a location accessible by the other projects in the solution (and other solutions). This reduced the build time for our main library from more then 10 minutes to less then 5 with comparable savings for other solutions.

However this also results in a problem with the precompiled header .pdb file as this file is being deleted by each project as a precompilation step. Suggested solutions on stackoverflow and on msdn for this problem is to copy the .pdb file as a precompilation step. However I couldn't get this to work (perhaps due to the copy step being executed before the automatic delete).

Alternative solution to fixing the pdb problem is setting the /C7 flag. For the debug build this results in a link warning warning LNK4206: precompiled type information not found; '...\msv\pch\x64\debug\stdafx.obj' not linked or overwritten; linking object as if no debug info'. This is not acceptable as indeed most debug information is missing during debug sessions. On msdn I found this article about the /Yi option but its not clear if this will resolve the problem (the LNK4206 is not mentioned) nor what the value of the symbol variable should be (must all missing symbols be added manually or just 1 arbitrary symbol)?

Any clues are welcome.

boojum
  • 181
  • 2
  • 15
  • 1
    Is building precompiled headers a major factor limiting built times of your projects? I doubt this. Probably it would be better to invest time into improving other projects files. – user7860670 Nov 07 '17 at 09:51
  • I agree with @VTT - unless there is tremendous churn in the shared header files of your code base, you're probably much better off managing the precompiled header build on a project-by-project basis. I did see one thing of interest in the first MSDN article you posted, though - user Reginald noted that you have to disable parallel builds in addition to implementing the copy in order to pull this off (in VS 2008 anyway). – Phil Brubaker Nov 07 '17 at 10:29
  • "sharing the same precompiled header" is the problem. I once figured out how to do this, forgot the details but it involved copying the .pch before building so each project still had its own .pch file. Decided against it because it made the build too convoluted. – Hans Passant Nov 09 '17 at 10:03

0 Answers0