Setting up C++ development environment on windows

This tutorial demonstrates how to set up a programming environment on a Windows PC using Visual Studio Code and Windows Subsystem for Linux (WSL). The tutorial includes step-by-step instructions on installing Visual Studio Code, setting up WSL, installing a compiler, linking Visual Studio Code to WSL, and installing extensions for C++ development.

Lets Go!

Thumbnail of Setting up C++ development environment on windows lesson

Setting up C++ development environment on windows

Lesson 2

Learn to install and configure a C++ compiler and IDE (such as Visual Studio or Code::Blocks) on a Windows system.

Get Started 🍁

Introduction to Programming Environment Setup on Windows

Welcome to our course, "Introduction to Programming Environment Setup on Windows"! In this course, you will learn how to set up a programming environment on a Windows PC using Visual Studio code and WSL (Windows Subsystem for Linux).

Before diving into the course, let's ask ourselves: Have you ever wondered how to seamlessly set up a programming environment on your Windows PC?

Throughout this course, you will be guided step-by-step on downloading and installing Visual Studio Code, configuring WSL, installing a compiler, linking Visual Studio Code to WSL, accessing files in your WSL terminal, and enhancing your coding experience with intellisense and color coding for C++.

No prior experience is required, just bring your curiosity and enthusiasm to learn! Join us on this exciting journey to set up a robust programming environment on your Windows PC. Happy learning!

Main Concepts of Setting Up a Programming Environment on Windows PC

  • Visual Studio Code:

    • Visual Studio Code is a text editor used for coding and programming.
    • It can be downloaded from code.visualstudio.com.
    • Installation involves downloading the executable file, running it, accepting terms, choosing settings, and installing it on your computer.
  • Compiling Programs with Powershell:

    • Powershell is used to compile programs on Windows.
    • Search for Powershell in the search bar and run it as an administrator.
    • Run the command WSL --install to install WSL (Windows Subsystem for Linux) which is required for compilation.
  • Installing Ubuntu for Compiling Programs:

    • After restarting your computer, open the app store and install Ubuntu.
    • The Ubuntu command line will be used for compiling programs.
    • Upon first startup, enter your username and password to access the Ubuntu terminal.
  • Installing GCC Compiler:

    • In the Ubuntu terminal, install the GCC compiler by running sudo apt install g++.
    • Follow the prompts and allow the installation to complete.
  • Linking Visual Studio Code with WSL:

    • In Visual Studio Code, install the WSL extension provided by Microsoft.
    • Connect Visual Studio Code to the WSL by clicking on the blue button in the bottom left corner and selecting "Connect to WSL".
  • Accessing Files in WSL:

    • WSL files can be accessed through the File Explorer by navigating to the Linux drive, then the Ubuntu folder, and finally the home directory with the corresponding username.
  • Enhancing Programming Experience:

    • Install the C/C++ extension from Microsoft in Visual Studio Code to have IntelliSense and code coloring for C++ programming.
    • This extension improves the coding experience in Visual Studio Code when working with C++ programs.

Practical Applications of Setting Up a Programming Environment on Windows PC

Step-by-Step Guide:

  1. Download Visual Studio Code:

    • Visit code.visualstudio.com.
    • Click the blue "download for Windows" button.
    • If the button doesn't specify Windows, use the dropdown arrow to select the appropriate installation.
    • Once downloaded, run the executable file.
    • Accept the terms, choose installation settings, and install the software.
  2. Set Up Powershell:

    • Search for "Powershell" in the search bar.
    • Run Windows PowerShell as an administrator.
    • Type WSL --install and hit enter to install WSL.
  3. Install Ubuntu:

    • Restart your computer after WSL installation.
    • Open the app store and search for "Ubuntu."
    • Click "Install" to download Ubuntu.
  4. Install GCC Compiler:

    • Open Ubuntu from the search bar.
    • Enter your username and password.
    • Install the GCC compiler by typing:
      sudo apt install update
      sudo apt-get install g++
      
  5. Link Visual Studio Code to WSL:

    • Search for WSL in Visual Studio Code extensions.
    • Install the WSL extension by Microsoft.
    • Click the blue button at the bottom left corner, then "Connect to WSL."
  6. Access WSL Files:

    • Open File Explorer and navigate to the Linux drive.
    • Go to the Ubuntu directory and access your files.
  7. Install IntelliSense for C++:

    • Search for C++ extension in the extensions bar of Visual Studio Code.
    • Install the Microsoft C/C++ extension for IntelliSense and coloring support.

Hands-On Engagement:

  1. Download Visual Studio Code on your Windows PC.
  2. Set up Powershell and install WSL.
  3. Install Ubuntu through the app store.
  4. Install the GCC compiler in Ubuntu.
  5. Link Visual Studio Code to WSL using the WSL extension.
  6. Explore and edit files in the WSL directory.
  7. Enhance your environment with IntelliSense for C++.

Get hands-on with setting up your programming environment using the WSL and Visual Studio Code. Happy coding!

Test your Knowledge

1/2

Which of the following is commonly used to compile C++ on Windows?

Advanced Insights into Setting Up a Programming Environment on Windows PC

In order to delve deeper into setting up a programming environment on your Windows PC using Visual Studio Code and WSL, consider the following advanced insights and tips:

  1. Customizing Visual Studio Code: Once you have Visual Studio Code installed, explore its various settings and extensions to tailor it to your preferences. You can change themes, key bindings, and install extensions for different programming languages to enhance your coding experience.

  2. Utilizing the WSL Terminal: The WSL terminal is a powerful tool that allows you to run Linux commands on Windows. Experiment with different commands, explore its capabilities, and familiarize yourself with its functionalities to maximize your programming productivity.

  3. Managing File System: Understanding how the WSL file system works is essential. Navigate through the Linux drive in your file explorer to access and manage files used by the WSL terminal. Remember that hidden files in Linux (starting with a period) may not be displayed by default.

  4. Installing IntelliSense and Coloring: Enhance your coding experience by installing IntelliSense and coloring for C++. These tools provide auto-completion, syntax highlighting, and code navigation features, making your coding process more efficient and error-free.

  5. Continuous Learning and Exploration: As you set up your programming environment, stay curious and open to learning new concepts and techniques. Seek out additional resources, online tutorials, and communities to expand your knowledge and skills in programming.

By embracing these advanced insights and further exploring the possibilities of Visual Studio Code and WSL, you can elevate your programming skills and create a conducive environment for coding projects. Happy coding!

Additional Resources for Setting Up a Programming Environment on Windows PC

Explore these resources to enhance your understanding of setting up a programming environment using the WSL and Visual Studio Code on Windows. Happy coding!

Practice

Task: Set up a development environment and write a simple C++ program to print your name.