LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-30-2018, 08:19 AM   #1
seke
LQ Newbie
 
Registered: Jul 2018
Location: south korea
Distribution: centos
Posts: 9

Rep: Reputation: Disabled
GCC_8.2.0 installation in linux: How do we use different version of GCC in linux?


The default gcc version on the system prior to this was gcc-4.7. I need the version 8.2 for C++ compilation.
I have installed gcc-8.2.0 through the following steps:
tar xzf gcc-4.6.2.tar.gz
cd gcc-8.2.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-8.2.0/configure --prefix=$HOME/GCC-8.2.0 --enable-languages=c,c++,fortran,go
make
make install
(The installation was done within the /Downloads directory)
After successful installation, the 'which gcc' or 'gcc --version' shows the gcc-4.7 and not gcc-8.2.
This is the outcome after installation of gcc-8.2
>> gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
How do I use the version 8.2 in this case? Is there a command that follows this step??
Thanks.
 
Old 07-30-2018, 08:30 AM   #2
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,978

Rep: Reputation: 271Reputation: 271Reputation: 271
What does
Code:
whereis gcc
return? I suspect 4.4.7 is installed /usr/bin/gcc, 8.2 in /usr/local/bin. Why not install the package gcc-8.2? Why keep around an ancient version?
 
Old 07-30-2018, 08:34 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,885
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Did you wish to keep the older version?

If not, you should install the newer version in place of the older version.

Typically you would use "sudo make install" and also the configure line would not specify a --prefix option and would instead use the default location for the compiler, such as /usr/bin/gcc.

Note that Red Hat 4.4 ended LTS last year.
 
Old 07-30-2018, 08:49 AM   #4
seke
LQ Newbie
 
Registered: Jul 2018
Location: south korea
Distribution: centos
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by RandomTroll View Post
What does
Code:
whereis gcc
return? I suspect 4.4.7 is installed /usr/bin/gcc, 8.2 in /usr/local/bin. Why not install the package gcc-8.2? Why keep around an ancient version?
This is the result of the search:

$ whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

Also, are you suggesting i remove version 4.7 and install gcc-8.2? I just installed 8.2 but 4.7 is the default still. Uninstalling gcc4.7 will effect other older sofwares. No?
 
Old 07-30-2018, 09:11 AM   #5
seke
LQ Newbie
 
Registered: Jul 2018
Location: south korea
Distribution: centos
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
Did you wish to keep the older version?

If not, you should install the newer version in place of the older version.

Typically you would use "sudo make install" and also the configure line would not specify a --prefix option and would instead use the default location for the compiler, such as /usr/bin/gcc.

Note that Red Hat 4.4 ended LTS last year.
I am using CentOS6. I have now removed the version 4.7 by "yum remove gcc" and also manually removed the gcc directory in usr/bin/ and usr/libexec/. Now i will procede with the installation as before??

tar xzf gcc-4.6.2.tar.gz
cd gcc-8.2.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
./configure //$PWD/../gcc-8.2.0/configure --prefix=$HOME/GCC-8.2.0 --enable-languages=c,c++,fortran,go
make -j 4
make install -j 4

is this correct ??
 
Old 07-30-2018, 09:39 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,885
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Recommend you remove the --prefix term
 
Old 07-30-2018, 09:45 AM   #7
seke
LQ Newbie
 
Registered: Jul 2018
Location: south korea
Distribution: centos
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
Recommend you remove the --prefix term
I tried that. But now after removing gcc4.7 i am getting "error: no acceptable C compiler found in $PATH"

output:

[biopo5]# $PWD/../gcc-8.2.0/configure --enable-languages=c,c++,fortran,go

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for libmpx support... yes
checking for libhsail-rt support... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/keretsu/Downloads/buildobj':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

was it a mistake to remove all gcc directories from /usr/lib and /usr/libexec/gcc ??

Appreciate you help.
 
Old 07-30-2018, 09:48 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,885
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
That makes sense actually. You removed the compiler, therefore you cannot build a new one, because there's no longer a compiler.

Best that you install using the package manager, as RandomTroll suggested.
 
  


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
How to find Linux kernel & gcc version taichiman Linux - Hardware 4 04-12-2016 09:20 PM
[SOLVED] The latest gcc/g++ version we can find on a linux distribution is 4.6.3 ? esgol Linux - Newbie 7 07-10-2012 07:14 AM
Problem during installation for GCC version 3.0 strewberry SUSE / openSUSE 6 08-21-2011 05:40 AM
Linux From Scratch - Version 6.7 GCC-4.5.1 - Pass 2 Error on libiberty.an antonio.moschini@nsn.com Linux From Scratch 3 03-28-2011 03:48 AM
Changing hostname in Linux and gcc installation Sailesh Linux - Newbie 1 07-26-2006 01:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:58 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