LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-25-2012, 09:09 AM   #1
jack.sully
Member
 
Registered: Jul 2012
Posts: 38

Rep: Reputation: Disabled
Unable to compile C++ code.


Hi,
I am using Ubuntu Linux 8.10.
I am unable to compile C++ codes.I have downloaded two packages but unable to install them.

-rw-r--r-- 1 surendra surendra 3035754 2011-03-15 22:40 g++-4.2_4.2.4-1ubuntu3_amd64.deb
-rw-r--r-- 1 surendra surendra 2784498 2011-03-15 22:42 g++-4.2_4.2.4-1ubuntu3_i386.deb

This is th error I am getting.

surendra@ubuntu:~$ sudo apt-get install g++-4.2_4.2.4-1ubuntu3_i386.deb
[sudo] password for surendra:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package g++-4.2_4.2.4-1ubuntu3_i386.deb

surendra@ubuntu:~$ sudo apt-get install g++-4.2_4.2.4-1ubuntu3_amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package g++-4.2_4.2.4-1ubuntu3_amd64.deb
 
Old 07-25-2012, 09:26 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,311

Rep: Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574
"apt-get install" downloads and installs packages.

For already downloaded packages, please use : sudo dpkg -i <package>.deb

Besides that : A g++ package has multiple dependencies ..
1) gcc-base-<version>, 2) cpp-<version>, 3) gcc-<version>, 4) ??



.

Last edited by knudfl; 07-25-2012 at 09:40 AM.
 
Old 07-25-2012, 11:27 AM   #3
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.2
Posts: 7,809
Blog Entries: 58

Rep: Reputation: Disabled
Run this:
Code:
sudo apt-get install build-essential
That gets you gcc, and other odds'n'sods necessary for compiling C and C++.
 
1 members found this post helpful.
Old 07-25-2012, 01:31 PM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,311

Rep: Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574
# 3 : Agreed, but may be the OP has no internet ?
Or is using the long gone obsolete "sources.list" ?

An /etc/apt/sources.list pointing to "the old archive" should have a text like this:
Code:
deb http://old-releases.ubuntu.com/ubuntu/ intrepid main restricted
deb http://old-releases.ubuntu.com/ubuntu/ intrepid multiverse universe
deb http://old-releases.ubuntu.com/ubuntu/ intrepid-updates main restricted
deb http://old-releases.ubuntu.com/ubuntu/ intrepid-updates multiverse universe
deb http://old-releases.ubuntu.com/ubuntu/ intrepid-backports main restricted
deb http://old-releases.ubuntu.com/ubuntu/ intrepid-backports multiverse universe
deb http://old-releases.ubuntu.com/ubuntu/ intrepid-security main restricted
deb http://old-releases.ubuntu.com/ubuntu/ intrepid-security multiverse universe

Last edited by knudfl; 07-25-2012 at 01:32 PM.
 
Old 07-25-2012, 06:47 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,456

Rep: Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601
a question?
Quote:
I am using Ubuntu Linux 8.10.
ubuntu 8 ?
 
Old 07-26-2012, 03:38 AM   #6
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.2
Posts: 7,809
Blog Entries: 58

Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
a question?

ubuntu 8 ?
Ooops! Never noticed that. Gone past its sell-by date.
 
Old 07-26-2012, 04:11 AM   #7
jack.sully
Member
 
Registered: Jul 2012
Posts: 38

Original Poster
Rep: Reputation: Disabled
surendra@ubuntu:~$ sudo apt-get install build-essential
[sudo] password for surendra:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package build-essential

@ubuntu:~$ sudo dpkg -i g++-4.2_4.2.4-1ubuntu3_i386.deb
dpkg: error processing g++-4.2_4.2.4-1ubuntu3_i386.deb (--install):
package architecture (i386) does not match system (amd64)
Errors were encountered while processing:
g++-4.2_4.2.4-1ubuntu3_i386.deb

@ubuntu:~$ sudo dpkg -i g++-4.2_4.2.4-1ubuntu3_amd64.deb
Selecting previously deselected package g++-4.2.
(Reading database ... 99179 files and directories currently installed.)
Unpacking g++-4.2 (from g++-4.2_4.2.4-1ubuntu3_amd64.deb) ...
dpkg: dependency problems prevent configuration of g++-4.2:
g++-4.2 depends on gcc-4.2 (= 4.2.4-1ubuntu3); however:
Package gcc-4.2 is not installed.
g++-4.2 depends on gcc-4.2-base (= 4.2.4-1ubuntu3); however:
Package gcc-4.2-base is not installed.
g++-4.2 depends on libstdc++6-4.2-dev (= 4.2.4-1ubuntu3); however:
Package libstdc++6-4.2-dev is not installed.
dpkg: error processing g++-4.2 (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db ...
Errors were encountered while processing:
g++-4.2

surendra@ubuntu:~$ apt-get install
E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

root@ubuntu:/home/surendra# apt-get install
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++-4.2: Depends: gcc-4.2 (= 4.2.4-1ubuntu3) but it is not installable
Depends: gcc-4.2-base (= 4.2.4-1ubuntu3) but it is not installable
Depends: libstdc++6-4.2-dev (= 4.2.4-1ubuntu3) but it is not installable
E: Unmet dependencies. Try using -f.
root@ubuntu:/home/surendra# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
g++-4.2
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 6959kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 99189 files and directories currently installed.)
Removing g++-4.2 ...
Processing triggers for man-db ...

Still not working,,,,,,,,,
 
Old 07-26-2012, 04:16 AM   #8
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.2
Posts: 7,809
Blog Entries: 58

Rep: Reputation: Disabled
Probably because 8.10 is no longer supported. You might be better updating to 12.04.
 
Old 07-26-2012, 12:03 PM   #9
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,311

Rep: Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574Reputation: 3574
The default '8.10' compiler is version 4.3.2 :

sudo apt-get install g++

And / or : sudo apt-get install build-essential ( See post # 3 ).
 
Old 08-02-2012, 01:00 AM   #10
jack.sully
Member
 
Registered: Jul 2012
Posts: 38

Original Poster
Rep: Reputation: Disabled
root@ubuntu:/home/surendra# sudo apt-get install g++
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package g
root@ubuntu:/home/surendra#
root@ubuntu:/home/surendra#
root@ubuntu:/home/surendra# sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package build-essential

Still the same
 
Old 08-02-2012, 01:11 AM   #11
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,025

Rep: Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399
Hi,

to enable apt-get to work please do the following (as root or with sudo):

1. Confirm that your /etc/apt/sources.list looks like what is shown by knudfl in post #3
2. Run "apt-get update"
3. Confirm no errors are reported by step 2. -> If there are errors post them here
4. Only try this if there are no errors: "apt-get install build-essential"

Evo2.

PS. As pointed out already Ubuntu 8.10 is no longer supported so you should seriously consider upgrading or installing something current.
 
Old 08-02-2012, 07:54 AM   #12
jack.sully
Member
 
Registered: Jul 2012
Posts: 38

Original Poster
Rep: Reputation: Disabled
root@ubuntu:/etc/apt# less sources.list

#deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Release amd64 (20081029.2)]/ intrepid main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://us.archive.ubuntu.com/ubuntu/ intrepid main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ intrepid universe
deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid universe
deb http://us.archive.ubuntu.com/ubuntu/ intrepid-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ intrepid multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid multiverse
deb http://us.archive.ubuntu.com/ubuntu/ intrepid-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid-updates multiverse

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://us.archive.ubuntu.com/ubuntu/ intrepid-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid-backports main restricted universe multiverse

i will try to upgrade
 
Old 08-02-2012, 08:49 AM   #13
jack.sully
Member
 
Registered: Jul 2012
Posts: 38

Original Poster
Rep: Reputation: Disabled
Thanks a lot it's working now.

surendra@ubuntu:~$ g++ one.cpp
surendra@ubuntu:~$ ./a.out
Hello
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to compile a c++ code in vi? nehapawar Linux - Newbie 4 08-12-2009 11:16 AM
Unable to compile C++ code kirtimaan_bkn Programming 8 07-01-2006 07:40 AM
compile C code in G++ lucky6969b Programming 25 01-04-2006 09:51 PM
First Post! Unable to compile source code J--Lew Linux - Newbie 5 08-16-2005 04:17 PM
I can't compile c++ code with g++ malb Programming 5 07-25-2005 07:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration