LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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
 
LinkBack Search this Thread
Old 01-11-2009, 12:32 PM   #1
Denisius
Member
 
Registered: Aug 2007
Location: Israel
Distribution: Slackware
Posts: 66

Rep: Reputation: 15
Using different GCC versions


Hello.

I have 2 compilers installed on a shell, 3.3.6 and 4.2. I have a certain source code that needs to be compiled with the former.

How do I do that?
 
Old 01-11-2009, 12:38 PM   #2
manwithaplan
Member
 
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Rep: Reputation: 45
There's a handy tool called gcc-config. You might need to install it. Run
Quote:
gcc-config -l
this will show you a list of installed gcc's. Then
Quote:
gcc-config "the version listed you want to use"
This will change gcc's. Then run the same commands to revert back.
 
Old 01-11-2009, 12:43 PM   #3
Denisius
Member
 
Registered: Aug 2007
Location: Israel
Distribution: Slackware
Posts: 66

Original Poster
Rep: Reputation: 15
I've checked and it is not installed, and I can't seem to find a download for it. Do you have a link? and will it work without having root access?
 
Old 01-11-2009, 01:04 PM   #4
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by Denisius View Post
Hello.

I have 2 compilers installed on a shell, 3.3.6 and 4.2. I have a certain source code that needs to be compiled with the former.

How do I do that?
Instead of running "make" run "make CC=gcc-3.3.6 CXX=gcc-3.3.6-g++".
CC variable specifies C compiler executable, CXX specifies C++ compiler executable. In C only projects you don't have to specify "CXX=..." part. But make sure that on your system gcc 3.3.6 executable is named gcc-3.3.6 (and g++ for 3.3.6 is named gcc-3.3.6-g++) and not something else.
 
Old 01-11-2009, 01:08 PM   #5
Denisius
Member
 
Registered: Aug 2007
Location: Israel
Distribution: Slackware
Posts: 66

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ErV View Post
Instead of running "make" run "make CC=gcc-3.3.6 CXX=gcc-3.3.6-g++".
CC variable specifies C compiler executable, CXX specifies C++ compiler executable. In C only projects you don't have to specify "CXX=..." part. But make sure that on your system gcc 3.3.6 executable is named gcc-3.3.6 (and g++ for 3.3.6 is named gcc-3.3.6-g++) and not something else.
I get the following error:
Quote:
gcc-3.3.6: installation problem, cannot exec `cc1': No such file or directory
 
Old 01-11-2009, 02:26 PM   #6
almatic
Member
 
Registered: Mar 2007
Distribution: Debian
Posts: 547

Rep: Reputation: 66
you can also just make new symlinks for gcc, g++ and cpp to the versions you want to use.

ln -sf /usr/bin/gcc-3.3.6 /usr/bin/gcc

and so on.
 
Old 01-12-2009, 05:54 AM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2013.07, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,222

Rep: Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381Reputation: 2381
Quote:
gcc-3.3.6: installation problem, cannot exec `cc1': No such file or directory
I think, I can guess, what is going on : May be, you used
2 Slackware packages to have 2 compilers.
That is simply not possible with 3.3.x / 4.x, too many conflicts.

The solution is to remove the "extra compiler" with # 'removepkg'
Next : Reinstall the system compiler to insure, that everything
is in place.

To make an extra usable compiler package, e.g. gcc-4.x :
Unpack gcc-4.x--.tgz in a new directory in /home .
Delete conflicting files, rename files in usr/bin :
1) delete install/doinst.sh
2) delete usr/lib/libgcc_s.so.1
3) in usr/bin : mv cpp cpp-4.1 ( or 4.2 if that's the version )
4) in usr/bin : mv gcov gcov-4.1 ( 4.2..)
and delete usr/bin/gccbug.
5) delete usr/share usr/doc usr/include usr/man usr/info
and usr/lib/classpath .

Use # 'makepkg' to repack ( use a new package name )
Say yes to 'chmod 0755'

If the above is a compiler, capable of working in that system,
it can now do it with no conflicts, and without overwriting
"system compiler files", when installed.
....
Good luck !
....

Last edited by knudfl; 01-12-2009 at 06:27 AM.
 
Old 01-12-2009, 06:04 AM   #8
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You can use the "-V 3.3.6" argument it gcc version 3.36 is installed. You may just have a gcc33 package. I don't know if that would be version 3.3.6.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc versions compatibility with kernel versions.. mahesh_manthapuri Suse/Novell 1 03-22-2006 12:28 AM
Is it possible to have two different versions of GCC in the same system ?? nasty_daemon Linux - Software 2 09-07-2005 10:49 AM
switching between gcc versions DrAMac Debian 2 08-30-2005 05:21 PM
Can you have two different versions of gcc on the same system? the theorist Linux - Software 1 02-23-2004 04:53 PM
changing gcc versions SirRobbin Linux - Newbie 0 08-27-2003 09:54 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration