LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   how to install old gcc (https://www.linuxquestions.org/questions/slackware-14/how-to-install-old-gcc-287169/)

pengStudent 02-07-2005 02:37 AM

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.

__J 02-07-2005 02:49 AM

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

pengStudent 02-07-2005 07:00 AM

thanks, I'll get started on this right away.

pengStudent 02-07-2005 03:53 PM

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.

__J 02-07-2005 04:02 PM

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

figadiablo 02-16-2005 08:27 PM

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

DaHammer 02-16-2005 10:59 PM

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


DaHammer 02-16-2005 11:05 PM

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.


All times are GMT -5. The time now is 12:14 PM.