Can't install g++

Yo chaps.

So. While I was trying to compile lighttpd from source (first time I've ever been so brave) I ran across this error:
"C compiler cannot create executables"

I Googled around a bit and found someone suggesting that the error came from not having g++ installed. Which makes sense.

So I tried:

> apt-get install g++
...
The following packages have unmet dependencies.
  g++: Depends: g++-4.1 (>= 4.1.1-2) but it is not going to be installed

If I then tried to install g++-4.1 and got a similar error, and traced it right down to having the wrong version of libc6:

g++-4.1: Depends: libstdc++6-4.1-dev (= 4.1.1-21) but it is not going to be installed
....
libstdc++6-4.1-dev: Depends: libc6-dev (>= 2.3.6-7) but it is not going to be installed
...
libc6-dev: Depends: libc6 (= 2.3.6.ds1-13etch8) but 2.7-18 is to be installed

Now. If it was a less important package I'd just remove it and then re-install it. But to do that with libc6 I'd have to uninstall about 30 system packages including apt, which I'm not that inclined to do.

Does anyone know of a way around this?

Oh by the way, here's my apt sources list (might be relevant):

deb ftp://ftp.uk.debian.org/debian/ stable main contrib non-free
deb-src ftp://ftp.uk.debian.org/debian/ stable main

deb http://security.debian.org/ stable/updates main

Cheers,
Robin

Yo, indeed, my good fellow.

You should be able to upgrade libc6 without uninstalling. Even on debian.

This should do it:

aptitude update
aptitude upgrade
aptitude install g++

By the way, I suggest changing the 'stable' keyword in your sources.list to the release you use (woody/sarge/etch). It happened before that packages got broken because of this when a new release got out.

Indeed, and it might be the case here, as well.
Lenny was recently released.

...You could also try:

apt-get update
apt-get upgrade
apt-get install build-essential

Instead of apt-get, you can use aptitude, if aptitude is the package manager that you prefer.

build-essential is a metapackage which includes several useful libraries.