LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-07-2005, 03:37 AM   #1
pengStudent
Member
 
Registered: Nov 2003
Location: California
Distribution: Slackware 14
Posts: 55

Rep: Reputation: 15
how to install old gcc


I have slackware 10 installed right now with gcc-3.3 installed. I have some programs that require to be compiled with gcc-2.95, and was wondering how to install an older version of gcc on slackware 10? Is it possible to install to another location so it doesn't replace gcc-3.3, maybe placing it in /opt or /usr/local ? Thanks for the help guys.
 
Old 02-07-2005, 03:49 AM   #2
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
easily.

download and extract the gcc-2.95 (I use 2.95.3 (it's the most bug free of the series))

configure and build it. The way I do it is: ( I should point out that it is recommended to use a build directory instead of building in the top source directory. to do this, cd to the gcc-2.95 directory, do mkdir build, cd build, then execute the configure command below like this:
../configure etc... (notice the two .. before the / in the command)).

./configure --prefix=/opt/gcc-2.95.3 --enable-shared --with-languages=c,c++ --enable-threads=posix --enable-__cxa_atexit

make

make install

one thing you might want is to disable shared (--disable-shared) libraries if you don't want to have to put the libstdc++ libraries and such in your library path (and to build static executables, which are easier to manage if they have to be run on another computer with a different distro or something) but it will make the size of the binary a little bigger.

to use the new compiler, just modify your path to point to the new one first:

Code:
export PATH=/opt/gcc-2.95.3/bin:$PATH
then type in:
Code:
gcc -v
to verify that it is your new installation of gcc instead of the default 3.3 compiler

or

Code:
unset CC
Code:
export CC=/opt/gcc-2.95.3/bin/gcc
if your gonna compile apps with it, make this symlink

Code:
ln -s /opt/gcc-2.95.3/bin/gcc /opt/gcc-2.95.3/bin/cc

Last edited by __J; 02-07-2005 at 03:52 AM.
 
Old 02-07-2005, 08:00 AM   #3
pengStudent
Member
 
Registered: Nov 2003
Location: California
Distribution: Slackware 14
Posts: 55

Original Poster
Rep: Reputation: 15
thanks, I'll get started on this right away.
 
Old 02-07-2005, 04:53 PM   #4
pengStudent
Member
 
Registered: Nov 2003
Location: California
Distribution: Slackware 14
Posts: 55

Original Poster
Rep: Reputation: 15
Hey, this works awsome. The only other thing I need to figure out is how to switch between both 3.3 and 2.95 ? I would like to keep 3.3 as the default compiler, and be able to choose the 2.95 compiler when I need it.
 
Old 02-07-2005, 05:02 PM   #5
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
thats where the PATH and CC come in. you can use either one, doesn't matter. unless you specifically do:

Code:
export PATH=/opt/gcc-2.95.3/bin:$PATH
the 3.3 compiler will be used. just export the line above to use 2.95
 
Old 02-16-2005, 09:27 PM   #6
figadiablo
Member
 
Registered: Feb 2002
Location: Virginia USA
Distribution: Slackware, CentOS, Fedora
Posts: 342

Rep: Reputation: 30
Hi there,

I tried the above suggestion, but I get the following error when compiling.

Code:
gcc -c  -DIN_GCC   -g -O2     -I. -I.. -I../../../gcc/ch -I../../../gcc/ch/.. -I../../../gcc/ch/../config -I../../../gcc/ch/../../include ../../../gcc/ch/expr.c
gcc -c  -DIN_GCC   -g -O2     -I. -I.. -I../../../gcc/ch -I../../../gcc/ch/.. -I../../../gcc/ch/../config -I../../../gcc/ch/../../include ../../../gcc/ch/loop.c
../../../gcc/ch/loop.c:321:8: missing terminating " character
../../../gcc/ch/loop.c:322:38: missing terminating " character
make[2]: *** [loop.o] Error 1
make[2]: Leaving directory `/home/figa/Downloads/gcc-2.95.2/build/gcc/ch'
make[1]: *** [cc1chill] Error 2
make[1]: Leaving directory `/home/figa/Downloads/gcc-2.95.2/build/gcc'
make: *** [all-gcc] Error 2
Any suggestions?

Figa
 
Old 02-16-2005, 11:59 PM   #7
DaHammer
Member
 
Registered: Oct 2003
Location: Planet Earth
Distribution: Slackware, LFS
Posts: 561

Rep: Reputation: 30
I'd suggest creating a symlink to gcc-2.95.3 and use that when you want to use it instead of the native version.

Code:
ln -s /opt/gcc-2.95.3/bin/gcc /usr/bin/gcc-2.95.3
When you want to use gcc-2.95.3, execute "gcc-2.95.3" vs "gcc". If you're compiling packages that use autoconf, ie have configure scripts and etc, then you can use just set CC to whatever version you want.

Code:
export CC=gcc-2.95.3

Also, if you compiled gcc-2.95.3 with shared library support, then you can add it's library location to /etc/ld.so.conf.
Code:
echo "/opt/gcc-2.95.3/lib" >> /etc/ld.so.conf
ldconfig

Last edited by DaHammer; 02-17-2005 at 12:02 AM.
 
Old 02-17-2005, 12:05 AM   #8
DaHammer
Member
 
Registered: Oct 2003
Location: Planet Earth
Distribution: Slackware, LFS
Posts: 561

Rep: Reputation: 30
Quote:
Originally posted by figadiablo
Hi there,

I tried the above suggestion, but I get the following error when compiling.

Code:
make[2]: *** [loop.o] Error 1
make[2]: Leaving directory `/home/figa/Downloads/gcc-2.95.2/build/gcc/ch'
make[1]: *** [cc1chill] Error 2
make[1]: Leaving directory `/home/figa/Downloads/gcc-2.95.2/build/gcc'
make: *** [all-gcc] Error 2
Any suggestions?

Figa
Looks like you are trying to compile chill support. If you don't need it, then I suggest not compiling it. If you do, then you're in for alot of headaches getting it to compile, probably. Anyway, you can disable it by using "--enable-languages=c,c++" on your configure line.
 
  


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 install gcc? xelt Linux - Newbie 4 04-13-2005 11:03 AM
gcc wont install, 'failed dependencies: glibc-devel is needed by gcc-3.3.3-41' TdlSnare SUSE / openSUSE 3 11-29-2004 03:13 PM
What is GCC and how to you install it? lazicsavo Linux - Software 5 10-25-2004 02:58 PM
Must have gcc to install gcc? thafusion Linux - Software 4 05-28-2004 11:20 PM
cc....gcc....install??? sparrot Linux - Newbie 10 03-31-2003 09:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:10 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration