92

I am trying to install G++ compiler in Ubuntu 13.10. It told me I needed to install the build-essential package.

I have tried the below code

sudo apt-get update
sudo apt-get install build-essential

It gives me this error:

Reading package lists... Done
Building dependency tree 
Reading state information... Done
E: Couldn't find package build-essential
3
  • 1
    did you find build essential package on synaptic and software-center? Jan 1, 2014 at 12:59
  • what is build-essential good for?
    – sharkant
    Apr 29, 2017 at 11:02
  • 1
    I encountered a similar problem. I solved it by entering 'sudo apt-get upgrade' after 'sudo apt-get update'. Oct 17, 2018 at 8:44

6 Answers 6

81

Type in the Terminal sudo apt-get install build-essential and then press key TAB instead of pressing ENTER.

5
  • 67
    Why does this solve the problem?
    – mafu
    Jan 14, 2017 at 19:21
  • It helped me install ubuntu-restricted-extras .. thanks!
    – eigil
    Mar 11, 2019 at 12:55
  • 2
    Did not work for me. Ubuntu 18.04.2
    – leetbacoon
    Jul 15, 2019 at 10:42
  • 5
    @mafu Because with the tab you actually enter ...essentials not ...essential.
    – thanos.a
    Jun 2, 2020 at 0:10
  • 1
    This works in Ubuntu 20.04 (LTS) x64. You have to enter TAB and then enter the ENTER key.
    – Isuru
    Dec 19, 2020 at 9:07
47

Enable main repository in Software & Updates.

Then run these commands in a terminal:

sudo apt-get update
sudo apt-get install build-essential
1
  • 1
    Note: build-essential includes the gcc/g++ C and C++ compilers, respectively, and other build tools, for anyone wondering. See: linuxconfig.org/…. Oct 21, 2021 at 21:23
9

You have to enable the main repository in the /etc/apt/sources.list file.
To accomplish this remove the '#' character in front of the following lines.

#deb http://de.archive.ubuntu.com/ubuntu/ saucy-updates main restricted
#deb-src http://de.archive.ubuntu.com/ubuntu/ saucy-updates main multiverse restricted universe

Save the file and execute
sudo apt-get update && sudo apt-get install build-essential.

0
7

Well, sometimes what happens is that if your first command fails due to some repo not responding or other network issues

sudo apt-get update

Then you may not be able to install build-essential. So always ensure that apt-get update completes successfully. Once update is commpleted, issue:

sudo apt-get install build-essential

Now you should be able to install it successfully.

2
  • He has declared in the question that he gets error for it. Mar 17, 2016 at 14:27
  • That's the reason I said that if there's an error, you have to run apt-get update again, to ensure that all repo's do respond. Sometimes repos don't respond due to network problem as that's the reason why I had an issue. Apr 4, 2016 at 8:13
2

You can also install build essentials from software center
Open it up, and search for "build essential"

2

These terminal commands should solve your problem:

First remove the Merge List by opening a terminal (Press Ctrl+Alt+T to launch) and run this command:

sudo rm /var/lib/apt/lists/* -vf

or

sudo rm -vf /var/lib/apt/lists/*

these command lines are interchangable

the options used are -v verbose

-v, --verbose explain what is being done

and -f force

-f, --force ignore nonexistent files and arguments, never prompt

If you are ever unsure about a command line or the options being used always refer to the manual page for the command. These can be accessed on the internet by searching for man and the command for example man rm or you can access the same information by typing exactly the same command in the terminal for example man rm instructions for quitting the page will be at the bottom of the terminal like this

picture of man page options

Next, generate a new one by running a simple update:

sudo apt-get update

Then do,

sudo apt-get install build-essential
1
  • Any drawback of removing all items in the "var/lib/apt/lists" folder?
    – Cloud Cho
    Apr 22, 2022 at 16:18

Not the answer you're looking for? Browse other questions tagged .