user451498
user451498

Reputation:

cl.exe not finding any standard include file

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.

Upvotes: 22

Views: 39875

Answers (2)

Ben Voigt
Ben Voigt

Reputation: 283793

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.

Upvotes: 32

Robert
Robert

Reputation: 6540

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.

Upvotes: 3

Related Questions