LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Multiple versions of GCC (http://www.linuxquestions.org/questions/slackware-14/multiple-versions-of-gcc-599326/)

Denisius 11-13-2007 09:55 AM

Multiple versions of GCC
 
How can i have 2 versions of GCC?

jowa45 11-13-2007 10:00 AM

By changing your search path to the one you want to engage.

John

Denisius 11-13-2007 10:01 AM

How do i do that?

duryodhan 11-13-2007 10:16 AM

export PATH=$PATH:<new_directory>

e.g export PATH=$PATH:/opt/gcc/bin/

run this in bash / put in bashrc.

Denisius 11-13-2007 10:19 AM

Do i build the other(older) GCC first?

David1357 11-13-2007 10:39 AM

Re: Multiple versions of GCC
 
Quote:

Originally Posted by Denisius (Post 2957595)
Do i build the other(older) GCC first?

Please give us more detail on what you are trying to accomplish so we can help you better.

For example: "I need gcc 2.95 and gcc 3.4.3 installed on the same machine. How do I do this?"

Denisius 11-13-2007 10:57 AM

Well, i already have the newest GCC installed on my machine, but i need an older version one installed as well, 3.3.6.

David1357 11-13-2007 11:05 AM

Re: Multiple versions of GCC
 
Quote:

Originally Posted by Denisius (Post 2957637)
Well, i already have the newest GCC installed on my machine, but i need an older version one installed as well, 3.3.6.

If you are building the older version from source, run configure with a prefix setting, e.g.
Code:

    # ./configure --prefix=/opt
    # make
    # make install

and it will be installed in /opt/bin instead of /usr/bin.

Then you can access the compiler directly using
Code:

    # /opt/bin/gcc
or by prefixing your path
Code:

    # export PATH=/opt/bin:$PATH
    # which gcc
    /opt/bin/gcc


H_TeXMeX_H 11-13-2007 11:46 AM

Check out this earlier thread ... I too wanted to know how it can be done:
http://www.linuxquestions.org/questi...of-gcc-594814/

I used gnashley's package, still here:
http://distro.ibiblio.org/pub/linux/...vel/gcc-3.4.6/

Denisius 11-14-2007 03:02 PM

When i compile it, it gives me a lot of warnings. Is that so for everyone?

Alien Bob 11-14-2007 03:13 PM

Maybe this package can help you out: http://www.slackware.com/~alien/slackbuilds/gcc34/

It installs gcc 3.4.x alongside (i.e. not overwriting) the gcc 4.x of Slackware 12.0. The original gcc 4.x compiler will still be default but applications that specifically look for a gcc3 compiler (such as QEMU) will find and use the gcc3 compiler.

My notes on how to invoke the gcc3 compiler instead of the default gcc4:

Code:

# This is a gcc34 compatibility SlackBuild for use in Slackware > 11.0 ,
# where gcc4 is the default compiler suite.
# This gcc34 build installs to /usr/gcc34 and will not interfere with gcc4.
# *** Use gcc34 in your scripts, as follows ***
# * By using environment variables:
#  Most softwares support the CC and CXX environment variables.
#  First assign them, then run configure and/or make. Example:
#    CC=gcc34 CXX=g++34 ./configure
#
# * Using configure support:
#  If the software is using the standard GNU automake and configure,
#  then there is a chance it supports other compilers by passing in
#  a setting to the configure script.
#  First run configure --help to see if it mentions anything.
#  The following example is from MPlayer:
#    ./configure --help
#    ./configure --cc=gcc34

Eric

David1357 11-15-2007 07:39 AM

Quote:

Originally Posted by David1357 (Post 2957646)
If you are building the older version from source, run configure with a prefix setting, e.g.
Code:

    # ./configure --prefix=/opt
    # make
    # make install

and it will be installed in /opt/bin instead of /usr/bin.

Then you can access the compiler directly using
Code:

    # /opt/bin/gcc
or by prefixing your path
Code:

    # export PATH=/opt/bin:$PATH
    # which gcc
    /opt/bin/gcc


I should have also added that you need to modify your library path to point to /opt/lib; however, other posters seem to have handled this links to the other thread.


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