Via sudo apt-get install gcc g++.
The following error occurred when installing GCC G++:
1. Use the following command to modify the source Open the source.list file
sudo gedit /etc/apt/sources.list
2. Add the following source to the opened file (add these two lines at the end)
-
deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
-
deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe
Perform the third step after saving.
3. Use the following command to update the source
sudo apt update
If E: Unable to obtain lock /var/lib/apt/lists/lock-open (11: The resource is temporarily unavailable) E: Unable to lock the directory /var/lib/apt/lists/
Then enter the command in the terminal
sudo rm /var/lib/apt/lists/lock
The terminal display will be as shown below.
This process may take a while
If it still does not work, please execute the following command to resolve the dependency
sudo apt-get install ncurses-dev
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install build-essential
4. Use commands to install g++4.9, gcc4.9
sudo apt install g++-4.9
sudo apt install gcc-4.9