2024年2月8日发(作者:)

Visual C++ 中fatal error C1083的解决办法00文/蹇安安

0 0 0

最近在做VC开发的过程中遇到了这个烦人的问题,查阅了很多资料也没有一个统一的说法,所以把所有可能出现的情况都总结一下,供以后参考。

0

0 0症状:0 0 0

fatal error C1083: Cannot open compiler intermediate file:“C:WINDOWSTempxxxx” No such file or directory

0 0 0

或0 0 0

0 0 0

致命错误 C1083: 无法打开编译器中间文件:

< tmp 目录 >; < tmpfile >: 没有的文件或目录

0 0 0

原因之一:有可能是环境变量设置不对。user用户变量和system变量TEMP和TMP的变量值都为%SystemRoot%TEMP ,在正常机器上,这是没有问题的,但是有的用户机器的系统盘是手动更改成C盘的,本来应该为E盘。

0 0 0

解决办法:将user用户变量和system变量TEMP和TMP的变量值都改为C:WINDOWSTemp

0 0 0

原因之二:和预编译头的设置有关。0 0 0

解决办法:打开Settings对话框,左边的Settings For中选中Release,底下的TreeView中选中,右边选中C/C++标签页,Category选Precompiled Headers,底下选Create precompiled header,Through header填StdAfx.h。左边的TreeView中依次选中工程中其他所有的cpp,Precompiled

Headers都选中Use precompiled header file,Through header填StdAfx.h。最后,“OK”、“Rebuild All”。

0 0 0

0 0 0

原因三:该错误是由 TMP 环境变量的末尾分号引起的。例如:TMP=C:TMP;

解决办法:从命令行设置 TMP 环境变量正确方法是,如下所示:C:>SET

TMP=C:TMP

0 0 0

非常重要的环境字符串不能结束用分号 (;),因为编译器将中间文件名追加到 TMP 路径。 通过从路径中删除分号,编译器可以正确地创建该文件。

0

0 0in addition,TMP variable should be fully qualified path and not

relative path。C:TMP for example may cause compiler to issue similar

errors,but C:TMP will always work correctly。 TMP environment variable

also should be set to that has sufficient space for compiler 's temporary

files drive。

0 0 0

另附上Windows帮助文档片段:RESOLUTION

0 0 0

0 0 0

To work around this error, specify the /Yc compiler option switch to

create a pre-compiled header file.

0 0 0

STATUS

0 0 0

Microsoft has confirmed this to be a problem in the Microsoft products

listed above. We are researching this problem and will post new

information here in the Microsoft Knowledge Base as it becomes available.

0 0 0

This problem does not occur in Microsoft C/C++ 32-bit compiler version

8.0, included with Visual C++ 32-bit Edition version 1.0.

0 0 0

MORE INFORMATION

0 0 0

0 0 0

The following code example demonstrates this problem.

Sample Code - TEST.C

/*

0 0 0

0 0 0

0 0 0

* Compiler options needed: / to demonstrate error

*/

0 0 0

#include

void main()

0 0 0

0 0 0

{0 0 0

0 0 0

printf("Hello, worldn");

}0 0 0

0