cl.exe not finding any standard include file

南楼画角 提交于 2019-12-04 15:37:58

问题


I found this sample code on the msdn library

#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 Line I store this code in file.cpp I then go to the command prompt and type this

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

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

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


回答1:


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.bat from the program directory.

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




回答2:


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.



来源:https://stackoverflow.com/questions/4505362/cl-exe-not-finding-any-standard-include-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!