Skip to main content

C++ Development in Linux

OS: Ubuntu 20.04 LTS

Setting up VSCode

  1. Install VS Code if not already installed.
  2. Install C/C++ extension if not already installed.
  3. Install C/C++ Project Generator extension.
  4. Check C++ compiler version g++ --version

    Default installation location for external libraries is /usr/local/

Using VS Code Project Generator Extension

Create a project

  1. Go to command pallete ctrl + shift + p
    image
  2. Search for "Create C project" or "Create c++ project" depending on your preference
  3. Create a new folder and select.
  4. A folder structure similar to this will be created.
    image
  5. It will create main.c or main.cpp under src and a generic Makefile.

Make commands

  • Build project:
    make all
  • Clean project:
    make clean
  • Build and run:
    make run

Modifying Makefile

  • Additional include files can be added to this line separated by commas.
    image

  • Change the executable file name
    image

  • Change the folder names
    image