Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The first thing to say is: "I am noob", so please be patient and don't laugh.. too much on me. I need to install c / c++ compiler and I heard that the best thing to do is to install gcc/g++ for that purpose (I think I don't have it on my machine).

maistora@maistora:~$ gcc --version
bash: gcc: command not found

I also read if I install build-essential the c/c++ compiler comes with it. So what I did is:

maistora@maistora:~$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 build-essential : Depends: libc6-dev but it is not going to be installed or
                            libc-dev
                   Depends: gcc (>= 4:4.4.3) but it is not going to be installed
                   Depends: g++ (>= 4:4.4.3) but it is not going to be installed
E: Broken packages

Then, I don't know why but I decided to install the dependencies one by one and started with the libc6-dev and this is the output:

maistora@maistora:~$ sudo apt-get install libc6-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libc6-dev : Depends: libc6 (= 2.11.2-10) but 2.13-21 is to be installed
             Depends: libc-dev-bin (= 2.11.2-10) but it is not going to be installed
             Recommends: gcc but it is not going to be installed or
                         c-compiler
E: Broken packages

And the next thing I did is:

maistora@maistora:~$ sudo apt-get install libc6
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libc6 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

which seem very strange to me. But I'm sure that something basic for you. So, my question is - how can I install build-essentials on my Debian 6 Squeeze or any work-around to install gcc/g++.

P.S. If I write sudo apt-get install gcc I will get to the beginning of my post and ending with libc6 is already the newest version. (hope I make my point clear). Thanks in advance.

share|improve this question
    
I read a post that says the person managed to fix this problem with downgrading some libraries. I am not sure what I am doing so I decided to ask here. –  Maistora Nov 11 '11 at 22:30
add comment

2 Answers 2

up vote 2 down vote accepted

You appear to have a mixture of Debian stable (squeeze) and Debian testing (wheezy) or unstable (sid). Specifically, your libc6 package is the testing/unstable version, but your package sources point to stable.

You need to pick a distribution between stable, testing and unstable — you can't really mix them (you can mix testing and unstable if you don't mind the occasional annoyance, but stable is too far apart).

If you pick stable, you need to downgrade your system. Downgrading is supported by apt-get, but you can expect some pain as not all packages support downgrading. Since you're new to Debian, I recommend reinstalling unless you've already customized your system a lot. You can save and restore your home directory; also back up the /etc directory, but restore files from it only on a case-by-case basis.

If you pick testing or unstable, edit your software sources in /etc/apt/sources.list to have testing or wheezy or unstable or sid where it now says stable or squeeze.

You're right that installing the build-essential package is a good way to install development tools, by the way. And gcc is the de facto standard C and C++ compiler on Linux; you would only use another if you had very special requirements.

share|improve this answer
    
Very good answer, thanks. –  Maistora Nov 12 '11 at 9:15
add comment

Just open /etc/apt/sources.list

and add these lines:

deb http://packages.dotdeb.org squeeze all
deb-src http://packages.dotdeb.org squeeze all

Save it, then do

apt-get update
apt-get upgrade

then you will see the packages will be installed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.