7

While trying to compile a program with the following command:

g++ -o <output_file> <my_file.cpp>

I found the following report....

The program 'g++' can be found in the following packages:
 * g++
 * pentium-builder
 Try: sudo apt-get install <selected package>

Then I tried...

nawshad@ubuntu:~/Thesis/Codes/Thesis_Utility_Function/Test Codes$ sudo apt-get   install   g++
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 g++ : Depends: g++-4.6 (>= 4.6.3-1~) but it is not going to be installed
 libqt4-opengl : Depends: libqtcore4 (= 4:4.8.1-0ubuntu4.1) but 4:4.8.1-0ubuntu4 is to be installed
                 Depends: libqtgui4 (= 4:4.8.1-0ubuntu4.1) but 4:4.8.1-0ubuntu4 is to be installed
 libqt4-svg : Depends: libqtcore4 (= 4:4.8.1-0ubuntu4.1) but 4:4.8.1-0ubuntu4 is to be installed
              Depends: libqtgui4 (= 4:4.8.1-0ubuntu4.1) but 4:4.8.1-0ubuntu4 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

I can't install due to unmet dependencies.


While updating, the following error occurs:

nawshad@ubuntu:~$ sudo apt-get update
[sudo] password for nawshad:
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

I followed the instructions at Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?), but the unmet dependencies are still not resolved.

1 Answers1

7

Run:

sudo apt-get update

You should always run that before installing or upgrading packages on the command-line (unless you've run it very recently). It fetches information about what packages are available in what versions from where.

You may simply be able to install g++ now, but go ahead and do as Web-E says (after running the above command), to fix any currently broken dependencies:

sudo apt-get -f install

(The -f can actually go before or after the install; the effect is the same.)

Then try installing g++ again:

sudo apt-get install g++

If that still fails, please edit your question to show any error messages (and also the output of the above two commands when you ran them). But it should succeed.

Eliah Kagan
  • 117,780
  • while updating following error occurs: nawshad@ubuntu:~$ sudo apt-get update [sudo] password for nawshad: E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable) E: Unable to lock directory /var/lib/apt/lists/ E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? – MiNdFrEaK Aug 14 '12 at 05:26
  • 1
    @MiNdFrEaK Do you have other open package management programs, like the Update Manager, the Software Center, Synaptic, or another running instance of apt-get? (Also, in the future, to share output from the command-line, you should edit your question; usually it is very difficult to read it without proper formatting, which it almost never has when posted in a comment.) – Eliah Kagan Aug 14 '12 at 05:28
  • Sorry, I am very new in this group, I'll edit my question at later comments, yes I do have, its Ubuntu Software Center. – MiNdFrEaK Aug 14 '12 at 05:48
  • @MiNdFrEaK Quit the Software Center and try running those commands again. This should eliminate the Could not get lock errors. – Eliah Kagan Aug 14 '12 at 05:49
  • 1
    @MiNdFrEaK If the problem still of the lock still exists, try taking a look at How do I unlock /var/lib/apt/lists ? – Nitin Venkatesh Aug 14 '12 at 06:08
  • Now,after updating, I ran the above commands serially, but the unmet dependencies are not resolved. – MiNdFrEaK Aug 16 '12 at 02:52
  • @MiNdFrEaK Please try Steps 1-5 of this procedure. That may solve your problem. If not, please edit your question to provide all the text from the Terminal, from Step 5. – Eliah Kagan Aug 16 '12 at 10:43
  • @EliahKagan Thank you guy.. Your answer was very useful for me – FindOutIslamNow Feb 04 '14 at 00:47