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
Eliah Kagan
  • 117,780
Jaffer Sadhique
  • 921
  • 1
  • 6
  • 3

6 Answers6

81

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

Parto
  • 15,325
  • 24
  • 86
  • 117
Ngoc
  • 859
  • 6
  • 3
47

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
  • 117,780
Avinash Raj
  • 78,556
  • 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
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.

ElefantPhace
  • 3,190
  • 3
  • 18
  • 29
Peter Parker
  • 351
  • 2
  • 8
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.

Ketan Patel
  • 81
  • 1
  • 2
  • He has declared in the question that he gets error for it. – Mostafa Ahangarha Mar 17 '16 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. – 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,190
  • 3
  • 18
  • 29
Meow
  • 1,357
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