C/C++ Dev Environment Using VS Code
VS Code is polyglot. This post will show how to setup VS code for C/C++ development.
Join the DZone community and get the full member experience.Join For Free
One Ring to rule them all,
One Ring to find them,
One Ring to bring them all
and in the darkness bind them.
― J.R.R. Tolkien, The Fellowship of the Ring
Whether you are a Lord of the Rings movie fan or not, you will agree that uniformity appeals to almost every one, and having a unified development experience is something developers strive and welcome all the time.
For a long time, development environment(s) have been tightly coupled with a particular technology e.g. Visual Studio for a mostly .NET-based development. We have seen heated debates among developers where they endlessly argue about one tool over another. This will never end, and it shouldn’t because many times these arguments results in awesome tooling, which we are using today.
In this post, I will share with you a simple C/C++ development environment setup using VS Code. If you are already using VS Code with some other programming language, then you are already half-way there. For others, they can check how the setup looks like and if they might wanna give it a try.
VS Code is a light-weight, open-source, free, and extensible IDE, and it is getting better every day. I use it frequently for my Node.js development work, and in this post I will show you how easy it is start with C/C++ development using same IDE and have the similar experience.
- Install Visual Studio Code (Typical Installation, download installer from this link).
- Download and setup MinGW.
- VS Code C/C++ extensions setup.
MinGW is a native Windows port of the GNU Compiler Collection (GCC), with freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All of MinGW’s software will execute on the 64bit Windows platforms.
You can download MinGW installer from this link. Once downloaded you can double-click to start setup wizard. Also make sure that you are connected to internet.
You will be also asked to select the package. I selected the mingw g++ as follows. After selection from the menu, click Apply.
Once installation is done, you will find a folder on your C: drive name MinGW. There is a bin folder inside that, and we need to include path to that bin folder to environment variable, so that later it can be found by VS code.
VS Code C/C++ Extensions Setup
From visual studio extensions tab, search for C/C++ extension and install it as follows:
Another handy extension, you wanna install is Code Runner. This extension will make it very easy for you to run your code.
After installing both extension, restart your VS-Code and we are all ready to write some C/C++.
Although this post is not about C/C++ programming itself, but here are few simple programs written in C and C++ to verify the code execution.
Temperature Conversion example code and its output.
VS Code can be used with various programming languages. I found using VS code very convenient for C/C++ development as well. Its not the only choice though but it is an easy one to setup and start with. Now, we have setup the tooling, we are ready to write some cool code and I will write some more posts about C/C++ programming in next posts. Till next time, Happy Coding.
- sourceforge.net/projects/mingw/ (minGW installer)
Published at DZone with permission of Jawad Hasan Shani. See the original article here.
Opinions expressed by DZone contributors are their own.
Tech Hiring: Trends, Predictions, and Strategies for Success
Getting Started With Istio in AWS EKS for Multicluster Setup
Top 10 Engineering KPIs Technical Leaders Should Know
What Is Envoy Proxy?