如何修复.pch文件丢失的生成? [英] How to fix .pch file missing on build?

查看:333
本文介绍了如何修复.pch文件丢失的生成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Visual Studio 2008中构建我的c ++解决方案时,它抱怨缺少xxxxx.pch文件。有没有设置我缺少,以获得预编译的标题回来?



这里是完整性的确切错误:

 错误1致命错误C1083:无法打开预编译头文件:'Debug\xxxxx.pch':没有这样的文件或目录


解决方案


  1. 在解决方案资源管理器中右键单击项目。

  2. 点击下拉菜单底部的属性。

  3. 在属性页面的左上角,
    选择所有配置

  4. 预编译标题:选择使用(/ Yu)
  5. li>
  6. 填写预编译头文件字段。标准是stdafx.h

  7. 点击确定


  8. 如果您的标头中没有stdafx.h文件放在那里。编辑
    到#include所有要预编译的头。


  9. 将一个名为stdafx.cpp的文件放入您的项目。 #includestdafx.h
    在其顶部,没有其他。

  10. 在解决方案资源管理器中右键单击stdafx.cpp。选择属性
    和所有配置,如步骤4 ...

  11. ...但此时选择预编译头创建(/ Yc)。这将只有
    绑定到一个文件stdafx.cpp。

  12. 将#includestdafx.h放在所有源文件的最顶端。
    (Unix或cygwin用户: find。-name* .cpp| xargs -n1 sed -i'1s / ^ /#includestdafx.h\\\
    / / code>)

幸运13.横过你的手指,点击Build。


When I build my c++ solution in Visual Studio 2008 it complains that the xxxxx.pch file is missing. Is there a setting I am missing to get the pre-compiled headers back?

here is the exact error for completeness:

Error   1   fatal error C1083: Cannot open precompiled header file: 'Debug\xxxxx.pch': No such file or directory

解决方案

  1. Right-click on your project in the Solution Explorer.
  2. Click Properties at the bottom of the drop-down menu.
  3. At the top left of the Properties Pages, select All Configurations from the drop-down menu.
  4. Open the C/C++ tree and select Precompiled Headers
  5. Precompiled Header: Select Use (/Yu)
  6. Fill in the Precompiled Header File field. Standard is stdafx.h
  7. Click Okay

  8. If you do not have stdafx.h in your Header Files put it there. Edit it to #include all the headers you want precompiled.

  9. Put a file named stdafx.cpp into your project. Put #include "stdafx.h" at the top of it, and nothing else.
  10. Right-click on stdafx.cpp in Solution Explorer. Select Properties and All configurations again as in step 4 ...
  11. ... but this time select Precompiled Header Create (/Yc). This will only bind to the one file stdafx.cpp.
  12. Put #include "stdafx.h" at the very top of all your source files. (Unix or cygwin users: find . -name "*.cpp" | xargs -n1 sed -i '1s/^/#include "stdafx.h"\n/')

Lucky 13. Cross your fingers and hit Build.

这篇关于如何修复.pch文件丢失的生成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆