LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 03-13-2013, 01:08 AM   #1
galfly
LQ Newbie
 
Registered: Aug 2010
Posts: 4

Rep: Reputation: 0
How to install gcc 4.2 on Ubuntu 12.04 or RedHat 5


Hi,

I need to compile a program that requires gcc 4.2. I tried a few things but maybe I am missing something. How can I install gcc 4.2?

Thanks
 
Old 03-13-2013, 01:16 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

instead of using an old compiler, can you not fix the code?

Evo2.
 
Old 03-13-2013, 01:42 AM   #3
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
You can get your desired compiler from here
Code:
./configure
make
make install
Bur before doing anything with compiler, you should read this.

Last edited by fortran; 03-13-2013 at 01:46 AM.
 
Old 03-13-2013, 01:49 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The default 4.x's for Ubuntu 12.04 :
sudo apt-get install g++-4.4 g++-4.5 g++-4.6

GCC 4.1.2, post #3 here ..
http://www.linuxquestions.org/questi...-4175450625/#3

Example building gcc-4.3 on Ubuntu 12.**, post #2 here ..
http://www.linuxquestions.org/questi...-4175452215/#2

-
 
Old 03-13-2013, 01:54 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Post # 3 :

No, pavi_kanetkar, you cannot configure gcc that way :
gcc requires a build directory outside the source directory.
+ "a lot of configure options"
Example: http://www.linuxquestions.org/questi...-4175452215/#2

And : Extra gcc's are always configured with option --program-suffix=<version>,
like : --program-suffix=42 : To insure no conflict with other installed gcc's.

-

Last edited by knudfl; 03-13-2013 at 01:57 AM.
 
Old 03-13-2013, 02:29 AM   #6
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
But I have downgraded my compiler version using this.
First I removed my latest compiler which was 4.4.5
then I downloaded and installed 4.2.2, and if I run gcc -v
it shows
gcc version 4.2.2
 
Old 03-13-2013, 03:19 AM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
# 6 .

No reason ever to remove the system compiler.
You can have as many version of gcc as you want, installed at the same time.
 
Old 03-13-2013, 03:23 AM   #8
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
As well as I have used multiple versions of gcc.
I gave the correct PATH (export PATH)and used the desired version.
 
Old 03-13-2013, 03:27 AM   #9
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Yes, Removing the old version is dangerous as it could cause you to kill dependancies for the distribution provided packages on your system.
I am just telling, it is possible.
 
Old 03-13-2013, 05:15 AM   #10
eklavya
Member
 
Registered: Mar 2013
Posts: 636

Rep: Reputation: 142Reputation: 142
What is current version of your compiler.
Code:
 $ gcc -v
If you are using ubuntu 12.04, may be you are using gcc-4.6.3.

As ubuntu version is increased, they drop the older version for installation and it is not possible to install it using apt-get.
You have to download the package and install it manually.
Ubuntu maintains the repository and you can download the deb file from here but I doubt your dependencies will support it.

If you install it using ./configure, make & make install, Do not remove older version. It will create an older version gcc file in /usr/bin.
You can set the path of your needed file and it will shift on your needed gcc version.

If you see in /usr/bin there is file named gcc, it is a linked file (not in centOS), if you follow the path, it is in same directory which is your current version of gcc.
You can set here your compiler if you find gcc-4.2 in /usr/bin but do not do this just use export to use your needed version.

I was telling you how does it work.
 
  


Reply



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
Install gcc-2.95.3 in ubuntu 10.04 luka11 Linux - Software 6 01-08-2017 11:51 AM
install gcc 3.4 along side gcc 4 problem on ubuntu 11.10 lilmike Linux - General 1 06-28-2012 04:39 AM
Redhat install gcc miamagoo Linux - Newbie 1 07-06-2010 12:56 PM
install gcc and c compiler into RedHat Linux spykid Linux - Newbie 4 10-25-2006 05:35 AM
redhat installation did not install gcc centr0 Linux - General 11 02-28-2003 08:50 PM

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

All times are GMT -5. The time now is 06:29 PM.

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
Open Source Consulting | Domain Registration