Building your C++ application with Visual Studio Code

Julia Reid

Did you know that you can build and debug C++ projects in Visual Studio Code with your compiler and debugger of choice? Although VS Code is a light-weight editor, you can set it up to resemble a full IDE, customizing IntelliSense, build, and debug configurations for your environment. 

There are two recommended approaches for building a C++ application in VS Code:  

  • Build with VS Code tasks  
  • Build with the CMake Tools extension 

If your project uses CMake, we recommend the CMake Tools extension for viewing, building, and debugging CMake targets. If you aren’t using CMake, you can define VS Code build tasks in tasks.json, which invoke your compiler of choice. 

Build with VS Code tasks

Watch this three-minute video tutorial to learn how to create a C++ build task in VS Code! This video shows how to invoke Clang on macOS, and the Hello World document tutorials below call out the specifics for other platforms.

Hello World tutorials

Build with the CMake Tools extension

If you build your project with CMake, you should use the CMake Tools extension to seamlessly view, build, and debug CMake targets in VS Code. Check out this Hello World tutorial for building a CMake project with CMake Tools. 

Remote building 

If you’d like to build a C++ application remotelyVS Code provides a ton of options, including remote-SSH, containers, WSL, and Codespaces. Check out this overview of remote development in VS Code to learn more! 

What do you think?

Download the C++ extension for Visual Studio Code today, give it a try, and let us know what you think. If you run into any issues, or have any suggestions, please report them in the Issues section of our GitHub repositoryYou can also join our Insiders program and get access to early builds of our release by going to File > Preferences > Settings and under Extensions > C/C++, change the “C_Cpp: Update Channel” to “Insiders”. 

We can be reached via the comments below or in email at visualcpp@microsoft.com. You can also find our team on Twitter at @VisualC 

1 comment

Discussion is closed. Login to edit/delete existing comments.

Feedback usabilla icon