0

I am trying to setup C++ to work on Visual Studio Code. I am using minGW for the compiler and have setup MinGW properly in the default location C:\MinGW. Here is my c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": ["${workspaceFolder}/**"],
            "defines": ["_DEBUG", "UNICODE", "_UNICODE"],
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "$('workspaceRoot')",
                    "C:\\MinGW\\lib\\gcc\\mingw32\\8.2.0\\include\\c++",
                    "C:\\MinGW\\lib\\gcc\\mingw32\\8.2.0"
                ]
            }
        }
    ],
    "version": 4
}

Here is my tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "C:/MinGW/bin/g++",
            "args": [
                "-g", "main.cpp"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Here is my settings.json:

{
    "files.associations": {
        "iostream": "cpp"
    }
}

When I try to build the solution, this message appears, despite of having a correct setup (atleast on the surface to a newbie):

> Executing task: C:/MinGW/bin/g++ -g main.cpp <

'C:\Users\Omkar' is not recognized as an internal or external command,
operable program or batch file.

D:\Projects\Tezi-Bois-Project\tezi-bois-hashcode>

Could someone please help me out with the setup and tell me where I am going wrong?

EDIT: I am trying to set up the environment using MinGW as my compiler, but I don't seem to find a solution on the thread provided as the answer nor is the comments useful. Any suggestions for the fix? My code isn't showing errors related to the compiler, its showing errors related to the location from where it's getting the file. The intellisense and the libraries are referred correctly and show appropriate errors.

Omkar
  • 340
  • 3
  • 14
  • 1
    Easy: [Download Visual Studio 2017 Community](https://visualstudio.microsoft.com/downloads/) and install it. – Swordfish Feb 28 '19 at 17:09
  • try using back slashes rather than forward slashes in your task command? Note that `c_cpp_properties.json` only affects code completion and has no effect on compilation – Alan Birtles Feb 28 '19 at 17:12
  • @AlanBirtles tried that. Problem persists. – Omkar Feb 28 '19 at 17:22
  • Looks as if some directory has spaces in its path. Try moving all the stuff to directories without spaces in the path. – Alexey B. Feb 28 '19 at 17:54
  • @AlexeyB. You seem to be correct. How do I fix this? I am looking for a solutions but dont seem to be in luck today. :/ – Omkar Feb 28 '19 at 18:36
  • @Omkar For a quick solution, move your code to a directory that does not have spaces in its path. For example, create a directory just in the root of C drive. – Alexey B. Feb 28 '19 at 18:40

0 Answers0