C++ cl.exe 未找到任何标准包含文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4505362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 15:34:45  来源:igfitidea点击:

cl.exe not finding any standard include file

c++msdnfatal-error

提问by Ben Voigt

I found this sample code on the msdn library

我在 msdn 库上找到了这个示例代码

#include <iostream>

int main()
{
    std::cout << "This is a native C++ program." << std::endl;
    return 0;
}

from How to Compile a Native C++ Program From the Command LineI store this code in file.cppI then go to the command prompt and type this

如何从命令行编译本机 C++ 程序我将此代码存储在file.cpp 中,然后转到命令提示符并键入

The output is as follows:

输出如下:

Current Path> cl /EHsc file.cpp

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86

Copyright (C) Microsoft Corporation. All rights reserved.

file.cpp file.cpp(1) : fatal error C1034: iostream: no include path set

当前路径> cl /EHsc file.cpp

适用于 80x86 的 Microsoft (R) 32 位 C/C++ 优化编译器版本 15.00.30729.01

版权所有 (C) 微软公司。版权所有。

file.cpp file.cpp(1):致命错误 C1034:iostream:未设置包含路径

I have the path variable set to the mirosoft sdk but I don't know what to do.

我将路径变量设置为 mirosoft sdk,但我不知道该怎么做。

I have tried multiple files like string.h and stdlib.h, but still no luck.

我尝试了多个文件,如 string.h 和 stdlib.h,但仍然没有运气。

回答by Ben Voigt

The Visual C++ compiler depends on a whole bunch of environment variables. The easiest way to get these set right is using the "Visual Studio Command Prompt" item created on the Start menu during the install, or running vcvars32.batfrom the program directory.

Visual C++ 编译器依赖于一大堆环境变量。正确设置这些设置的最简单方法是使用安装期间在“开始”菜单上创建的“Visual Studio 命令提示符”项,或vcvars32.bat从程序目录运行。

Otherwise, you'll have to set INCLUDE=and LIB=variables to the proper directories before getting a successful compile.

否则,你就必须设置INCLUDE=LIB=获得成功编译之前变量正确的目录。

回答by Robert

Did you really follow those instructions and use the Visual Studio command prompt, the one that sets up the directories the compiler should look in? If you did, you need to set up the environment variables specified in that article to point where they belong, or recreate the shell .bat file.

您是否真的遵循了这些说明并使用了 Visual Studio 命令提示符,即设置编译器应查看的目录的命令提示符?如果您这样做了,您需要设置该文章中指定的环境变量以指向它们所属的位置,或者重新创建 shell .bat 文件。