Triple CLang compiler Errors

I am redoing this course with the updated content and to refresh my C++. I noticed that compiling was really a problem this time though and I don’t remember having this much trouble with it in the previous version, but here is my solution for compiling errors with C++ in VSCode.

MinGW needs to be installed.

Go to http://mingw-w64.org to download the installer.
MS recommends performing a checksum on the file, instructions here:
How to quickly verify MD5, SHA1 and SHA2 (256, 384, 512) Checksum in Windows using Command Prompt - YouTube

Installing the MinGW takes quite a few steps and involves adding a certain directory to the computer’s System environment PATH variable. I followed these instructions to get my compiler working.

Once all of the g++, gdb, and gcc versions have been installed and the PATH has been added to the system variable VSCode must be configured to use the compiler, which can be accessed via F1.

Confirm that G++, GDB and GCC have been installed by using the --version check command in the command prompt. Also open developers Command Prompt(Comes with VSCommunity) and type ‘cl’ This should readout information about the MS Compiler and confirm everything was installed

A tasks.json preference file needs to be created that tells VSCode terminal where to look for a C++ compiler. This task will invoke the Microsoft C++ compiler to create an executable file based on the source code.

From the main menu, choose Terminal > Configure Default Build Task . In the dropdown, which will display a tasks dropdown listing various predefined build tasks for C++ compilers. Choose cl.exe build active file , which will build the file that is currently displayed (active) in the editor.

The inserted code should look like this:

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "shell",
      "label": "cl.exe build active file",
      "command": "cl.exe",
      "args": [
        "/Zi",
        "/EHsc",
        "/Fe:",
        "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "${file}"
      ],
      "problemMatcher": ["$msCompile"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

Then you can set your default compiler in the Terminal Menu.

On another note, make sure you are in Terminal, not Powershell, which will probably open by default. from there you should be able to type cl triplex.cpp and get the code to compile in VSCode.

1 Like

Thank you for this :slight_smile:

We’re all in it together - Harry S Tuttle

Privacy & Terms