1) "Undo build-essential" : sudo dpkg --purge build-essential
2) Installing the required build packages,
that build-essential was going to install :
All those packages could be downloaded on another computer,
and then installed. Move all new packages to a new folder.
And : sudo dpkg -i new-folder/*
I.e. dpkg will find out the install order itself.
( All packages can also be achieved from a DVD set
The packages are : ( I may have forgotten some.)
linux-libc-dev libc-dev-bin libc6-dev make m4 patch autoconf automake
libtool autotools-dev libltdl-dev
binutils base-files xz-utils cpp-4.6 gcc-4.6 g++-4.6 libstdc++6-4.6-dev