Setting the compiler path on Windows

In my computer c_cpp_properties.json file looks like this,

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

Is the compilerPath and intelliSenseMode are correct ?

or compilerPath should be something like this

C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++ 

or

C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe",

also intelliSenseMode should be “gcc-x64”, or “clang-x64” or “msvc-x64” ?

For instance in Microsoft Vs Code site above code changed to

{
    "configurations": [
        {
            "name": "Win32",
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "compilerPath": "C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe",
            "intelliSenseMode": "gcc-x64",
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],
                 "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ],
    "version": 4
}

https://code.visualstudio.com/docs/cpp/config-mingw#_configure-the-compiler-path

So the main problem is how can I be sure about the what to use in compilePath
Thanks

  • 1

    What are the symptoms that makes you question if the configuration is correct?

    – 




  • In other sites they are changed and made some additions os I cannot be sure which one I can use..

    – 

  • 2

    Please edit your question and claify what unexpected things that are happening in detail.

    – 

  • I can tell you that the compiler path should not be C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++

    – 

  • I am confused at what you are getting at here with the question. I believe you should prefer using / over \ as the path separator if that is the question.

    – 




To answer your question, in the official Visual Code documentation, you can see that the compiler path and intelliSenseMode are set as shown below. Just make sure to give the right location of g++.exe.

"compilerPath": "C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe",
"intelliSenseMode": "gcc-x64"

Update the question with what issues you are noticing if you have any.

The compilerPath and intelliSenseMode variables serve the purpose of configuring the VSCode editor to provide compilation and IntelliSense services respectively.

compilerPath

Because VSCode isn’t a full IDE by itself, it doesn’t ship with the compiler it needs to offer the compilation service. Therefore, it needs to be pointed in the direction of a valid C++ compiler. That is the purpose of the compilerPath variable. Testing whether or not the path you provided is correct is easy. Copy and paste it into a terminal (CMD or PowerShell) and see if the resulting output looks something like this:

PS C:\Users\neilb> C:\"Program Files"\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe
g++.exe: fatal error: no input files
compilation terminated.
PS C:\Users\neilb>

This means that the path is valid. If it isn’t, locate where your install of MinGW (the library that provides gcc and g++ support on Windows) is. If not already installed, do so.

inteliSenseMode

This tells VSCode what C++ style guide to follow for formatting code and providing linting features. The full list of options here is listed on the VSCode-cpptools GitHub page. What you have currently set should be adequate. (clang-x64)

Leave a Comment