关于VC编译错误fatal error C1083的解决办法

错误描述

fatal error C1083: Cannotopen precompiled header file: /'Debug/v13_3.pch/': No such file or directory 

原因及分析

This error results from a missing file - the compiled version of StdAfx.cpp. Visual C++ does a poor job of keeping track of this file and frequently "forgets" how to build it. This problem often occurs after restoring a saved workspace from diskette without the Debug directory. To fix the error select StdAfx.cpp from the workspace file list them choose Compile from the Build menu.  If that doesn't work the go to Project -> Settings, select the C/C++ tab, and click the radio button labeled Create Precompiled Headers.

Unexpected end while looking for precompiled header

翻译过来就是因为该模块没有包括预编译头文件“stdafx.h”的缘故。

VC用一个stdafx.cpp包含头文件stdafx.h,然后在stdafx.h里包含大部分系统头文件,这
样编译时VC就通过编译stdafx.cpp把大部分系统头文件预编译进来了,在Debug目录下有
一个很大的文件*.pch,这里就存储了预编译信息。
根据这个原理,如果这个pch损坏了或被删除了,系统重新编译时就会抱怨“cannot open
precompiled header file debug/*.pch”。

最终解决方案:

删除.pch,重新编译工程

关于 .pch 在工程中的设定

打开Project-》Setting对话框选C++页,将Category下拉式列表框选中Precompiled Headers

第一个选项“Not using....",这样就根本不用预编译头也不去寻找pch文件,就不会出错了,但是这样做的后果是每次编译、连接都化更多的时间。
第二个选项”Automatic ...",然后在“Through header”力填上stdafx.h,这样如果没有pch文件系统会自动生成一个pch,如果有的话就使用这个pch,这个          选项是比较“
智能”的。

第三个选项是强行创建一个pch文件

第四个选项是直接使用pch文件。当然“Throughheaders”里都填stdafx.h了。


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值