Skip to content

Instantly share code, notes, and snippets.

@rain1024
Last active May 9, 2022 06:58
Show Gist options
  • Save rain1024/6a008d11d44b8544408c1a52e9270bf4 to your computer and use it in GitHub Desktop.
Save rain1024/6a008d11d44b8544408c1a52e9270bf4 to your computer and use it in GitHub Desktop.
C++ programming with Visual Studio Code (Ubuntu 20.04)

C++ programming with Visual Studio Code (Ubuntu 20.04)

Install VS Code Ubuntu 20.04

sudo apt update && sudo apt-get upgrade --fix-missing 
sudo apt install build-essential checkinstall
sudo apt install ubuntu-restricted-extras
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt update
sudo apt install launchpad-getkeys
sudo launchpad-getkeys 
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
sudo git config --global user.name "YourName"
sudo git config --global user.email youremail@gmail.com


sudo apt update
sudo apt install software-properties-common apt-transport-https wget
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo snap install code --classic

Step: Install the C/C++ Extension Pack v1.2.0 for VS Code

Step: Install make and g++

sudo apt install make
sudo apt install g++

Step: Create file main.cpp

#include <iostream>
using namespace std;

int main(){
    cout << "Hello World\n";
    return 0;
}

Step: Create Makefile file

all: main

main:
	g++ --std=c++17 main.cpp -o main
	./main

clean:
	rm -rf main

Step: Compile and run

> make
g++ --std=c++17 main.cpp -o main
./main
Hello World

Step: Clean file

> make clean
rm -rf main
> ls 
main.cpp  Makefile

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment