Skip to main content

Installing VS Code and Compilers

VS Code

Visual Studio Code is a source-code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control and GitHub, syntax highlighting, intelligent code completion, snippets, and code refactoring.

Installing VS Code

Installing VS Code on Linux

There are a few different ways to install Visual Studio Code on a Linux system, depending on which version of Linux you are using.

Installing VS Code on Linux using .tar.gz

Using .tar.gz should work on most systems.

  • Download the latest version of Visual Studio Code from the official website: https://code.visualstudio.com/download

  • Open a terminal and navigate to the directory where you downloaded the VSCode package.

  • Use the tar command to extract the package, change into the extracted directory and run the install script

tar -xvf <package-name>.tar.gz
cd <extracted-directory>
./install.sh

This will install Visual Studio Code in the default location, which is /usr/share/code. You can then start Visual Studio Code by running the code command in the terminal.

Install on Different Path

To install Visual Studio Code to a different location, you can specify the --install-dir option when running the install script. ./install.sh --install-dir=/opt/vscode

This will install Visual Studio Code to the /opt/vscode directory. You will need to update your PATH environment variable to include this directory if you want to be able to run Visual Studio Code from the terminal.

For Debian and Ubuntu based distributions

Installing VS Code on Ubuntu using Package Manager

To install Visual Studio Code on a Ubuntu system using the package manager, follow these steps:

  • Open a terminal and update the package manager's package list.
sudo apt update
  • Install Visual Studio Code:
sudo apt install code

This will install Visual Studio Code and all of its dependencies. Once the installation is complete, you can start Visual Studio Code by running the code command in the terminal.

Installing VS Code on Ubuntu using .deb package

Alternatively, you can also install Visual Studio Code manually by downloading the .deb package from the official website and installing it using dpkg. To do this, follow these steps:

  • Download the latest version of Visual Studio Code from the official website: https://code.visualstudio.com/download

  • Open a terminal and navigate to the directory where you downloaded the .deb package.

  • Install the package using dpkg:

sudo dpkg -i <package-name>.deb

This will install Visual Studio Code and all of its dependencies.

You can then start Visual Studio Code by running the code command in the terminal.

For RHEL based distributions

To install Visual Studio Code (VS Code) on a Red Hat Enterprise Linux (RHEL) based distribution, follow these steps.

Installing VS Code on RHEL using Package Manager

To install Visual Studio Code (VS Code) on Red Hat Enterprise Linux (RHEL) using the yum package manager, follow these steps:

  • Add the official VS Code repository to your system. Run the following command to add the repository:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

  • Create a file called vscode.repo in the /etc/yum.repos.d/ directory with the following contents
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
  • Install VS Code using yum
sudo yum install code
  • You can launch VS Code by typing code in the terminal or by searching for it in the applications menu.

Installing VS Code on RHEL using .rpm package file

You can install VS Code by downloading the package file from the official website and installing it using the rpm command. To do this, follow these steps:

  • Download the VS Code package file from the official website:

    • Go to https://code.visualstudio.com/ in your web browser.

    • Click the "Download" button.

    • Select "Linux" as the operating system and click "Download .rpm". This will download the VS Code package file in the .rpm format.

  • Install the package file using the rpm command

    • Open a terminal and navigate to the directory where you downloaded the package file.

    • Run the following command to install VS Code. Replace <package_file> with the name of the package file you downloaded.

    sudo rpm -i <package_file>.rpm
  • Launch VS Code:

    • You can launch VS Code by typing code in the terminal or by searching for it in the applications menu.

Installing VS Code on Windows

To install Visual Studio Code (VS Code) on a Windows computer:

  • Go to the VS Code website (https://code.visualstudio.com/) and click on the "Download" button.

  • Select the Windows option to download the installation file.

  • Once the download is complete, double-click on the installation file to launch the setup wizard.

  • Follow the prompts in the setup wizard to complete the installation. This will typically involve accepting the license agreement and selecting the destination folder for the installation.

  • Once the installation is complete, you can launch VS Code by clicking on the shortcut icon that was created on your desktop or by searching for it in the Start menu.

  • That's it! You should now have VS Code installed on your Windows computer and be ready to start using it.

Installing VS Code on MacOS

To install Visual Studio Code (VS Code) on a Mac:

  • Go to the VS Code website (https://code.visualstudio.com/) and click on the "Download" button.

  • Select the Mac option to download the installation file.

  • Once the download is complete, double-click on the installation file to launch the VS Code installer.

  • Follow the prompts in the installer to complete the installation. This will typically involve accepting the license agreement and selecting the destination folder for the installation.

  • Once the installation is complete, you can launch VS Code by clicking on the shortcut icon in the "Applications" folder or by searching for it in Spotlight.

That's it! You should now have VS Code installed on your Mac and be ready to start using it.

Installing Compiler

Install GCC Compiler on Linux (Ubuntu)

The GNU Compiler Collection (GCC) is a collection of compilers and libraries for C, C++, Objective-C etc

To install the GCC compiler on a Linux Ubuntu system, follow these steps:

$ sudo apt update  #updating the packages list
$ sudo apt install build-essential # Install the build-essential package
$ sudo apt-get install manpages-dev # install the manual pages about using GNU/Linux for development
$ gcc --version # validate that the GCC compiler is successfully installed
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GCC is now installed on your system and you can start using it. To verify you can follow these steps:

  • Run the which command to check if the gcc executable is in your system's search path. If the gcc executable is found, the which command will display the path to the executable. For example:
$ which gcc
/usr/bin/gcc
  • Alternatively, you can use the dpkg command on Ubuntu system to check if the gcc package is installed on your system. This will display a list of all the installed packages that have "gcc" in their name. If the gcc package is installed, it will be listed in the output.
$ dpkg -l | grep gcc

ii gcc 4:9.3.0-1ubuntu2 amd64 GNU C compiler

The ii at the beginning of the line indicates that the package is installed and configured properly.

Installing MinGW on Windows

To install MinGW (Minimalist GNU for Windows) on a Windows computer:

  • Go to the MinGW website (https://mingw-w64.org/) and click on the "Downloads" tab.

  • Scroll down to the "Installer" section and click on the "Download Installer" button. This will download the MinGW installation file to your computer.

  • Once the download is complete, double-click on the installation file to launch the setup wizard.

  • Follow the prompts in the setup wizard to complete the installation. This will typically involve selecting the components you want to install and the destination folder for the installation. Be sure to select the "C Compiler" and "C++ Compiler" options to install the MinGW C and C++ compilers.

  • Once the installation is complete, you can open a command prompt and type "gcc -v" to verify that the compiler is working. You should see the version information for the GCC compiler if it is installed correctly.

That's it! You should now have MinGW installed on your Windows computer and be ready to start using the C and C++ compilers.

Setting environment variables for MinGW on Windows

  • Open the Start menu and search for "Environment Variables".

  • In the "Environment Variables" window, scroll down to the "System variables" section and click on the "Path" variable.

  • Click the "Edit" button to edit the path variable.

  • In the "Edit Environment Variable" window, click the "New" button and then type in the path to the MinGW bin directory. For example, if you installed MinGW in the default location, the path will be something like "C:\MinGW\bin".

  • Click "OK" to close the "Edit Environment Variable" window, and then click "OK" again to close the "Environment Variables" window.

This will add the MinGW bin directory to the system path, which allows you to use the MinGW compiler from any directory on your computer.

set the path

If you want to use MinGW with a development environment like Eclipse or Visual Studio Code, you may need to set the path to the MinGW compiler in the environment's settings. Consult the documentation for your development environment for more information on how to do this.