101

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
Eliah Kagan
  • 119,820

6 Answers6

91

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

Parto
  • 15,685
Ngoc
  • 959
  • 69
    Why does this solve the problem? – mafu Jan 14 '17 at 19:21
  • It helped me install ubuntu-restricted-extras .. thanks! – eigil Mar 11 '19 at 12:55
  • 3
    Did not work for me. Ubuntu 18.04.2 – leetbacoon Jul 15 '19 at 10:42
  • 5
    @mafu Because with the tab you actually enter ...essentials not ...essential. – thanos.a Jun 02 '20 at 00:10
  • 1
    This works in Ubuntu 20.04 (LTS) x64. You have to enter TAB and then enter the ENTER key. – Isuru Dec 19 '20 at 09:07
  • The OP and this answer uses the same sudo apt-get install build-essential command. So is correct the first comment of this answer. – Manuel Jordan Mar 30 '24 at 01:33
  • warning newcomers: build-essential is very outdated and does not guarentee all essential build tools anymore - you may still need to get some on your own that might be assumed "essential" (like git, autogen, autoconf, core dev libs, etc) For those who wonder what it is, it is/was the "starter" meta package so you could compile most things without having to download a million required packages, though it usually doesn't supply ALL your needed packages, it WILL supply a greater bulk of them. If you need to compile programs from source rather than a release/pkg, this is for you. – osirisgothra Jun 13 '25 at 17:35
  • footnote: when I say outdated, i mean on the older distros, the newer distros should have updated build-essential to include the modern "essentials" – osirisgothra Jun 13 '25 at 17:35
50

Enable main repository in Software & Updates.

Then run these commands in a terminal:

sudo apt-get update
sudo apt-get install build-essential
Eliah Kagan
  • 119,820
Avinash Raj
  • 80,616
  • 1
    Note: build-essential includes the gcc/g++ C and C++ compilers, respectively, and other build tools, for anyone wondering. See: https://linuxconfig.org/how-to-install-g-the-c-compiler-on-ubuntu-18-04-bionic-beaver-linux. – Gabriel Staples Oct 21 '21 at 21:23
10

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.

ElefantPhace
  • 3,291
9

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.

  • He has declared in the question that he gets error for it. – Mostafa Ahangarha Mar 17 '16 at 14:27
  • 1
    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. – Ketan Patel Apr 04 '16 at 08:13
2

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

ElefantPhace
  • 3,291
Meow
  • 1,427
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