Visual C++ fatal error C1083的解决办法
文/蹇安安
最近在做VC开发的过程中遇到了这个烦人的问题,查阅了很多资料也没有一个统一的说法,所以把所有可能出现的情况都总结一下,供以后参考。
症状:
fatal error C1083: Cannot open compiler intermediate file:“C:\WINDOWS\Temp\xxxx” No such file or directory
致命错误 C1083: 无法打开编译器中间文件:
< tmp 目录 >; \ < tmpfile >: 没有的文件或目录
原因之一:有可能是环境变量设置不对。user用户变量和system变量TEMP和TMP的变量值都
为%SystemRoot%\TEMP ,在正常机器上,这是没有问题的,但是有的用户机器的系统盘是手动更改成C盘的,本来应该为E盘。
解决办法:将user用户变量和system变量TEMP和TMP的变量值都改为C:\WINDOWS\Temp
原因之二:和预编译头的设置有关。
解决办法:打开Settings对话框,左边的Settings For中选中Release,底下的TreeView中选中StdAfx.cpp,右边选中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”。
原因三:该错误是由 TMP 环境变量的末尾分号引起的。例如:TMP=C:\TMP;
解决办法:从命令行设置 TMP 环境变量正确方法是,如下所示:C:\>SET TMP=C:\TMP
非常重要的环境字符串不能结束用分号 (;),因为编译器将中间文件名追加到 TMP 路径。 通过从路径中删除分号,编译器可以正确地创建该文件。
in 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。
另附上Windows帮助文档片段:
RESOLUTION
To work around this error, specify the /Yc compiler option switch to create a pre-compiled header file.
STATUS
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.
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.
MORE INFORMATION
The following code example demonstrates this problem.
Sample Code - TEST.C
编译器错误/*
* Compiler options needed: /Fptest.pch to demonstrate error
*/
#include <stdio.h>
void main()
{
  printf("Hello, world\n");
}
 
查看文章
 
,Error
20080310 星期一 13:14
可能很多人在安装VC 6.0后有过点击Compile”或者Build”后被出现的
,Error ”错误提示给郁闷过。很多人的
选择是重装,实际上这个问题很多情况下是由于路径设置的问题引起的,
CL.exe”是VC使用真正的编译器(编译程序),其路径在VC根目录\VC98\Bin”下面,
你可以到相应的路径下到这个应用程序。
因此问题可以按照以下方法解决:打开vc界面 点击VCTOOLS(工具)—>Option(选择)
—>Directories(目录)重新设置Excutable FilsInclude Files
Library FilesSource Files”的路径。很多情况可能就一个盘符的不同
(例如你的VC装在C,但是这些路径全部在D),改过来就OK了。

如果你是按照初始路径安装vc6.0的,路径应为:
executatble files:
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin
C:\Program Files\Microsoft Visual Studio\VC98\BIN
C:\Program Files\Microsoft Visual Studio\Common\TOOLS
C:\Program Files\Microsoft Visual Studio\Common\TOOLS\WINNT
include files:
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
library files:
C:\Program Files\Microsoft Visual Studio\VC98\LIB
C:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB
source files:
C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\CRT\SRC
如果你装在其他盘里,则仿照其路径变通就行(我就是装在D)
关键是microsoft visual studio\ 后面的东西要相同。
本人深受其害,重装多次不管用,上面中文部分为高手借鉴