1. Install gcc (preparation before installation)
Installing gcc under ubuntu reports an error:
sudo apt get install gcc
Waiting for cache lock: Unable to acquire lock /var/lib/dpkg/lock-frontend. Lock is being held by process 6809 (unattended-upgr)
Method 1: No solution
sudo rm /var/lib/dpkg/lock
Way 2:
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
2. Install vscode
sudo snap install code –classic
Successful installation
3. Find and add the plug-in in the ubuntu installation list
4. Edit and compile the code
gcc hello.cpp -o hello
Install gcc 's c++ compiler.
sudo apt-get install build-essential gdb
The executable file compiled by gcc can be run on ubuntu ( host x86 ).
reference
【1】 Get Started with C++ on Linux in Visual Studio Code
【3】
sudo rm /var/lib/dpkg/lock