Vscode-cpptools: Visual studio 2019 build tools provides error C1034: iostream: no include path set The terminal process terminated with exit code: 2

Created on 15 May 2019  路  19Comments  路  Source: microsoft/vscode-cpptools

Type: General
Input information below

Please review existing issues and our documentation at https://github.com/Microsoft/vscode-cpptools/tree/master/Documentation prior to filing an issue.

Describe the bug

  • OS and Version: widows 10
  • VS Code Version: code -v
    1.33.1
    51b0b28134d51361cf996d2f0a1c698247aeabd8
    x64

visual studio version:
NOT installed only build tools 2019 and c++ buildtools 2019

  • C/C++ Extension Version: current
  • Other extensions you installed (and if the issue persists after disabling them): some and yes
  • A clear and concise description of what the bug is.

Getting the following error when ompiling

helloworld.cpp
c:\Users\nicta\dev\c++\helloworld\helloworld.cpp(1): fatal error C1034: iostream: no include path set
The terminal process terminated with exit code: 2

To Reproduce
Please include code sample and task.json files.

c_cpp_properties.sjon
note same issue when using just "${workspaceFolder}/**", in include path

```(json)
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.20.27508\include",
"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt",
"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um",
"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared",
"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt",
"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt"

        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],

        "windowsSdkVersion": "10.0.17763.0", 
        "intelliSenseMode": "msvc-x64",
        "compilerPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.20.27508\\bin\\Hostx64\\x64\\cl.exe",
        "cStandard": "c11",
        "cppStandard": "c++17"
    }
],
"version": 4

}


task.json
```(json)
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "msvc build",
            "type": "shell",
            "command": "cl.exe",
            "args": [
                "/EHsc",
                "/Zi",
                "/Fe:",
                "helloworld.exe",
                "helloworld.cpp"
            ],
            "group":  {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal":"always"
            },
            "problemMatcher": "$msCompile"
        }
    ]
}

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

i pres ctrlshift b to build.
ans select c/c+: cl.exe build active file
(cant select task.json ?)

Expected behavior
it builds

builtasks need repro question

Most helpful comment

without changing annything i now get the following error in vscode ??

fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
The terminal process terminated with exit code: 1

(deleting obj file did not work)

All 19 comments

c_cpp_properties.json is just for configuring IntelliSense with our C/C++ extension and not building. The task.json has its own args you need to add something like
"/I", "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.20.27508\\include",
to the args.

You shouldn't have to add the system include path to the task. Do you get the same error when you try compiling in the Developer Command Prompt with the same arguments?

It works from the development console it just gives some error about the semantics but it does compile.

Could the issue be that the task.json is just not showing up ?

without changing annything i now get the following error in vscode ??

fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
The terminal process terminated with exit code: 1

(deleting obj file did not work)

For now i'm using a code runner to bind F8 to run cl on the current file. As a workaround

Issue not yet fixed

Are you saying that code runner works?
Did you open VS Code from inside the Developer Command Prompt so that it can inherit the build environment?

The code runner works and i opened VS Code from inside the Development console.
Do you need anny logs or info.

I am unable to reproduce your problem, but I don't know what's missing at this point. Perhaps it's because all of my machines have Visual Studio installed, but really that shouldn't matter since iostream comes with your BuildTools installation. If you type set in your VS Code terminal window (assuming CMD is your shell), do you see the correct build environment variables set?

We are unable to reproduce this problem. If you have any additional information you can share, please let us know and we can reopen the issue and investigate further. Thank you!

I get the errors too,
fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
config as the document say.

env:
msbuild tools vs 2019, version 14.21.27702
start from Developer Command Prompt,
errors:
fatal error LNK1112

I finded the solution, you should start code frome x64 Native Tools Command Prompt.
The the link error LNK1112 is gone

I ran into the same thing, but I was missing the first step from:
https://code.visualstudio.com/docs/cpp/config-msvc

i.e. "start VS Code from the Developer Command Prompt"

this one fixed it for me. It initializes all the needed env variables for you.

Thanks

Are we required to start VS code from the Developer command prompt always ?? That's not convenient.

@UtkarshBhatthere Yes, but there's an issue tracking a potential fix for that at https://github.com/microsoft/vscode-cpptools/issues/5271 .

Dear People from the future looking to solve your issue: Here is what we have figured out so far:

  • In case you get the error C1034: iostream: no include path set: If you haven't already, start VS code from the Developer Command Prompt that is installed with the MSVC compiler set. If you have everything resolved now, very good. If not, continue.

  • In case you get the error fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64', you need to start VS Code from the x64 Developer Command Prompt

@bobbrow I think you can ask this as issue as solved

Hi, starting your Developer Command Prompt every time, then navigating to the project source, starting the app there... Using this process every time we write code and compile seems to be tedious. Is there any other way of doing this, where we can directly start the app, write code, compile, and run code.

Well, it is the only way to get it working, as of now. If you are want and are able to, you could write a small script or such for opening that. But I am by no means a developer here. I only had this issue, and I had been trying to understand this here for a solid hour, so I wrote this summarizing note so others have it easier.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ecbrodie picture ecbrodie  路  3Comments

igorPhelype picture igorPhelype  路  3Comments

montery8 picture montery8  路  3Comments

arl picture arl  路  3Comments

wdc596933938 picture wdc596933938  路  3Comments