skip to Main Content

I run my C++ code on Visual Studio Code with the file extension .cpp but it’s not working. How can I run this on Visual Studio Code without using mingw? Is there any extension which can help me to run this code on Visual Studio Code?

2

Answers


  1. Visual studio code is just an IDE. With the Microsoft C/C++ Extension (https://code.visualstudio.com/docs/languages/cpp) it can do all the syntax checking / highlighting / IntelliSense / etc. But it does not have an in-built compiler. It relies on having suitable compiler / linker installed already.

    C++ is a compiled language meaning your program’s source code must be
    translated (compiled) before it can be run on your computer. The C/C++
    extension doesn’t include a C++ compiler or debugger, since VS Code as
    an editor relies on command-line tools for the development workflow.
    You need to install these tools or use the tools already installed on
    your computer.

    So, you need to install something like mingw, etc. See https://code.visualstudio.com/docs/languages/cpp#_install-a-compiler.

    Login or Signup to reply.
  2. Without a compiler like mingw (or another gcc variant), you can’t really compile or run c++ code. You maybe need to check the setup about installing gcc or clang in your environment.

    What You Can Do:

    1. Install gcc: sudo apt-get install g++ while using the remote WSL extension in Visual Studio Code.
    2. Download clang from LLVM’s official site and configure Visual Studio Code to use it.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search