title: warning LNK4206: precompiled type information not found; '' not linked or overwritten; linking object as if no debug info
body: <p>I'm looking at adding pre-compiled headers to our scons project. I followed this post <a href="http://chadaustin.me/2009/05/unintrusive-precompiled-headers-pch/" rel="nofollow">http://chadaustin.me/2009/05/unintrusive-precompiled-headers-pch/</a> and came up with</p>
  
  <pre><code>if ARGUMENTS.get('PRECOMPILED', 'FALSE') == 'TRUE':
      PCH, PCH_OBJ = env.PCH('precompiled.cpp')
      env['PCH'] = PCH
      env['PCHSTOP'] = 'precompiled.h'
      env.Append(CPPFLAGS=['/FI' + 'precompiled.h'])
  </code></pre>
  
  <p>The '/FI' means I don't need to manually add precompiled.h to each .cpp file.</p>
  
  <p>But... I'm getting a warning for each .obj file</p>
  
  <pre><code>warning LNK4206: precompiled type information not found;
  'xxx.obj' not linked or overwritten; linking object as if no debug info
  </code></pre>
  
  <p>which I can't seem to figure out. </p>
  
  <p>I'm not clear on the Microsoft documentation for this warning. <a href="http://msdn.microsoft.com/en-us/library/cf1aswwe.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/cf1aswwe.aspx</a></p>
  
  <blockquote>
    <p>The given object file, compiled with /Yc, was either not specified in the LINK command or was overwritten.</p>
  </blockquote>
  
  <p>How would I resolve this?</p>
  
  <blockquote>
    <p>A common scenario for this warning is when the .obj that was compiled with /Yc is in a library, and where there are no symbol references to that .obj from your code. In that case, the linker will not use (or even see) the .obj file. In this situation, you should recompile your code and use /Yl for the remaining objects (the objects that are not compiled with /Yc).</p>
  </blockquote>
  
  <p>I don't think this is my problem but maybe?</p>
  
  <p>scons run the following command line to create the pdb</p>
  
  <p>i.e.  env['PCHCOM']</p>
  
  <blockquote>
    <p>'$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'</p>
  </blockquote>
  
  <p>Which expands to 
  i.e. env.subst(env['PCHCOM'])</p>
  
  <blockquote>
    <p>'cl /Fo /TP /EHsc /nologo /errorReport:prompt /W3 /EHsc /Z7 /MD /O2 /FIprecompiled.h /DNDEBUG /D_UNICODE /DUNICODE /DWIN32 /DCSFUNIFIED_EXPORTS /DUNIFIED_DLL /IC /I: /I\ /ID /Ie /Iv /Ie /Il /Io /Ip /Im /Ie /In
     /It /I\ /Is /Iy /Is /It /Ie /Im /Is /Ie /Ir /Iv /Ii /Ic /Ie /I\ /Id
     /Ie /Ip /Ie /In /Id /Ie /In /Ic /Ii /Ie /Is /I\ /Ip /Ir /Ie /Ic /Io /Im /Ip /Ii /Il /Ie /Id /c /Ycprecompiled.h /Fp'</p>
  </blockquote>
  
  <h3>Update</h3>
  
  <p>Adding information requested by GaryO</p>
  
  <p>Note I've since updated the code to</p>
  
  <pre><code>if ARGUMENTS.get('PRECOMPILED', 'FALSE') == 'TRUE':
      PCH, PCH_OBJ = env.PCH('precompiled.cpp')
      env['PCH'] = PCH
      env['PCHSTOP'] = 'precompiled.h'
      env.Append(CPPFLAGS=['/FI' + 'precompiled.h'])
      env.Append(LIBS = PCH_OBJ)
  </code></pre>
  
  <p>in an attempt to resolve the warning.</p>
  
  <p>The command to create the pre-compiled header</p>
  
  <blockquote>
    <p>cl /Fodependencies\precompiled\precompiled.obj /TP /EHsc /nologo /errorReport:prompt /W3 /EHsc /Z7 /MD /O2 /FIprecompiled.h /DNDEBUG /D_UNICODE /DUNICODE /DWIN32  /Idependencies\precompiled /c dependencies\precompiled\precompiled.cpp /Ycprecompiled.h /Fpdependencies\precompiled\precompiled.pch</p>
  </blockquote>
  
  <p>Here is the link command</p>
  
  <blockquote>
    <p>link /nologo /DEBUG /OPT:REF /OPT:ICF /DEBUG /dll /out:out\windows-x86-MD-unicode-vs2008-rel\bin\csflogger.dll /implib:out\windows-x86-MD-unicode-vs2008-rel\bin\csflogger.lib dependencies\precompiled\precompiled.obj out\windows-x86-MD-unicode-vs2008-rel\bin\apr-1.lib out\windows-x86-MD-unicode-vs2008-rel\bin\aprutil-1.lib out\windows-x86-MD-unicode-vs2008-rel\bin\log4cxx.lib ws2_32.lib DnsAPI.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib psapi.lib out\windows-x86-MD-unicode-vs2008-rel\obj-shared\dependencies\csflogger\src\main\CSFLog.obj out\windows-x86-MD-unicode-vs2008-rel\obj-shared\dependencies\csflogger\src\main\VersionInfo.obj out\windows-x86-MD-unicode-vs2008-rel\obj-shared\dependencies\csflogger\src\main\logger_utils.obj out\windows-x86-MD-unicode-vs2008-rel\obj-shared\dependencies\csflogger\src\main\CSFLogger.obj</p>
  </blockquote>
  
  <p>On the initial build this does not produce a warning. However if I then modify the project (e.g. comment out a line in precomipled.h) I get the above warning. i.e. Even though the link command is the same.</p>
  
  <p>By adding</p>
  
  <blockquote>
    <p>env.Append(LIBS = PCH_OBJ)</p>
  </blockquote>
  
  <p>I thought I was fixing the issue. i.e. Because the .obj should be found. This can be seen in the link command</p>
  
  <blockquote>
    <p>dependencies\precompiled\precompiled.obj</p>
  </blockquote>
  
  <p>But it does not fix anything :(.</p>
  
  <p>For completeness here is the command used to compile with the pre-compiled header</p>
  
  <blockquote>
    <p>cl /Foout\windows-x86-MD-unicode-vs2008-rel\obj-shared\src\framework\SystemServiceDependencyInjector.obj /c src\framework\SystemServiceDependencyInjector.cpp /TP /EHsc /nologo /errorReport:prompt /W3 /EHsc /Z7 /MD /O2 /FIprecompiled.h -W3 -WX /wd4250 /wd4251 /DNDEBUG /D_UNICODE /DUNICODE /DWIN32 /DCSFUNIFIED_EXPORTS /DUNIFIED_DLL /DUSE_TR1_SMART_PTR /DUSE_TR1_SMART_PTR /DWIN32 /DCSFUNIFIED_EXPORTS /DUNIFIED_DLL /Idependencies\precompiled /Iinclude /Iapi /Itestutils /Idependencies\boost /Idependencies\csf2g-foundation\include\portability /Idependencies\csf2g-foundation\include\deprecated /Idependencies\csf2g-foundation\include /Idependencies\csflogger\include /Idependencies\log4cxx\include /Idependencies\libxml2\include /Idependencies\libcurl\include /Idependencies\libcurl\windows\include /Idependencies\ciscossl\releaseTempCiscoSSLTopFolder\inc32 /Idependencies\csf2g-idm\include /Idependencies\jcfcoreutils\include /Idependencies\httpdownloader\include /Idependencies\servicesframework\include /Idependencies\servicesframework\api /Idependencies\configservice-api /Idependencies\csf2g-foundation\include\dnsutils /Idependencies\csf2g-uc-service-locator\include /Idependencies\ucm9-config\include /Idependencies\ucm9-config\src /Idependencies\ucm9-config\src\dns /Idependencies\configservice\include /Idependencies\configservice\api /Idependencies\csfnetutils\include /Yuprecompiled.h "/Fpdependencies\precompiled\precompiled.pch"</p>
  </blockquote>
  
  <p>Again its the same for the scenario with &amp; without the warning.</p>