LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-06-2009, 10:03 PM   #1
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 136

Rep: Reputation: 17
Installing gcc


Hi all,

I'm new to Linux. I'd like to share my experience on installing gcc-4.4.1 with all others who have been stucked. Please give me some comments if anything can be done better.

The linux is I have is RHEL Client 5.3 x86_64, which comes with the gcc C compiler of earlier version I believe. I need to use g++ but RH does not have it in the repository.

My steps:

1a) Download and unpack GnuMP

cd ~
wget -c http://ftp.gnu.org/gnu/gmp/gmp-4.3.1.tar.gz
tar -zxvf gmp-4.3.1.tar.gz

1b) Build and Install GnuMP

mkdir gmp_build
cd gmp_build
../gmp-4.3.1/configure --prefix=/usr
make
make check
make install

1c) Copy the libraries from lib to lib64

cd /usr/lib
cp libgmp.so.3.5.0 /usr/lib64/
cd /usr/lib64
ln -s libgmp.so.3.5.0 libgmp.so.3
ln -s libgmp.so.3.5.0 libgmp.so

/* at this point, I'm confused why 3.5.0 and not 4.3.1 !!?? but anyway */

2a) Download and unpack MPRF

cd ~
wget -c http://www.mpfr.org/mpfr-current/mpfr-2.4.1.tar.gz
tar -zxvf mpfr-2.4.1.tar.gz

2b) Don't know the purpose, but anyway

export LD_LIBRARY_PATH=/usr/lib64

/* I'm going to find out why later */

2c) Build and Install MPRF

mkdir mpfr_build
cd mpfr_build
../mpfr-2.4.1/configure --prefix=/usr
make
make check
make install

2d) Copy the libraries from lib to lib64

cd /usr/lib
cp libmpfr.so.1.2.0 /usr/lib64/
cd /usr/lib64
ln -s libmpfr.so.1.2.0 libmpfr.so.1
ln -s libmpfr.so.1.2.0 libmpfr.so

/* and again why 1.2.0 not 2.4.1 ??!! */

3a) Download and Unpack GCC

cd ~
wget -c http://gcc.igor.onlinedirect.bg/rele...c-4.4.1.tar.gz
tar -zxvf gcc-4.4.1.tar.gz

3b) Build and Install GCC

mkdir gcc_build
cd gcc_build
../gcc-4.4.1/configure --prefix=/usr
make
make install

/* didn't do make check because it fails without autogen */

That's it. Try

g++ -v

Btw, at the time of writing, gcc-4.3.4 has just been released.
Please let me know if I have done anything wrong or anything to improve. Thanks.
 
Old 08-06-2009, 10:25 PM   #2
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,362

Rep: Reputation: 171Reputation: 171
Quote:
[fred@localhost ~]$ yum info gcc-c++
Loaded plugins: fastestmirror
Installed Packages
Name : gcc-c++
Arch : x86_64
Version : 4.1.2
Release : 44.el5
Size : 7.5 M
Repo : installed
Summary : C++ support for GCC
URL : http://gcc.gnu.org
License : GPL
Description: This package adds C++ support to the GNU Compiler Collection. It
: includes support for most of the current C++ specification,
: including templates and exception handling.
Ok, on a rpm based distro replacing the GCC version WILL break the system (as in a non functioning system). You can run a parallel install of another version. The question is usually what is required in the newer version that is not in the older version. There is actually very little in 4.3 that is not available in 4.1.
 
Old 08-06-2009, 11:11 PM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,522

Rep: Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503Reputation: 2503
And by the way, is also wrong to think,
that you need to install gmp and mpfr.

You don't !

Unpacking the gmp and mpfr tarballs into
the gcc source will do.

The recommended build method for gcc is here
http://www.linuxfromscratch.org/lfs/view/6.4/
gcc pass 1
http://www.linuxfromscratch.org/lfs/...gcc-pass1.html
gcc pass 2
http://www.linuxfromscratch.org/lfs/...gcc-pass2.html
gcc "pass 3"
http://www.linuxfromscratch.org/lfs/...ter06/gcc.html
.....

The c++ compiler for Redhat EL 5.x is provided
by the package 'gcc-c++' ( version 4.1.2 )
And
the package 'gcc43-c++' .... version 4.3.2 ...

Having all three installed is versatile
( There is also a 'compat-gcc-34-c++' )
... doing e.g. './configure CC=gcc-43 CXX=g++-34' ).
.....

Last edited by knudfl; 08-06-2009 at 11:31 PM.
 
Old 08-06-2009, 11:35 PM   #4
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,362

Rep: Reputation: 171Reputation: 171
knudfl is correct I missed the 4.3 part.

Quote:
[fred@localhost ~]$ yum info gcc43-c++
Loaded plugins: fastestmirror
Installed Packages
Name : gcc43-c++
Arch : x86_64
Version : 4.3.2
Release : 7.el5
Size : 9.6 M
Repo : installed
Summary : C++ support for GCC version 4.3 preview
URL : http://gcc.gnu.org
License : GPLv3+ and GPLv2+ with exceptions
Description: This package adds C++ support to preview of the GNU Compiler
: Collection version 4.3. It includes support for most of the
: current C++ specification and a lot of support for the upcoming C++
: specification.
 
Old 08-06-2009, 11:35 PM   #5
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 136

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by lazlow View Post
Ok, on a rpm based distro replacing the GCC version WILL break the system (as in a non functioning system). You can run a parallel install of another version. The question is usually what is required in the newer version that is not in the older version. There is actually very little in 4.3 that is not available in 4.1.
mmm... don't quite get it. When the system was freshly installed, did a "gcc a.cpp" and it complainted about cc1plus not available, and "g++ a.cpp" was not good neither. But yet "yum info gcc" gave the status 'Installed'.

So, if starting all over again, how could I do it smarter so that I could have my cpp source code compiled and linked?

Many thanks.
 
Old 08-07-2009, 12:26 AM   #6
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Quote:
mmm... don't quite get it. When the system was freshly installed, did a "gcc a.cpp" and it complainted about cc1plus not available, and "g++ a.cpp" was not good neither. But yet "yum info gcc" gave the status 'Installed'.
GCC is a bit of a confusing term, to be honest. It can refer to either the GCC C compiler or to all of the GCC compilers (including the C compiler but also the C++ compiler (g++), the java compiler (GCJ), etc.). It seems to make sense to me that all you have installed by default is the C compiler; that is why the system failed to compile your C++ code.

Anyway, on most system you can install build-essential, which includes all of the elementary compilers and other development tools.
 
Old 08-07-2009, 01:44 AM   #7
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,705
Blog Entries: 1

Rep: Reputation: 220Reputation: 220Reputation: 220
Since you don't sudo or su to execute make install, I presume you are doing everything as root. Bad habit, break it now. You don't need to be root to configure and compile software. Or even install software if you install it in your $HOME.

Changes in red...
Quote:
Originally Posted by Jerry Mcguire View Post
../gmp-4.3.1/configure --prefix=/usr --libdir=/usr/lib64 --enable-cxx --enable-mpbsd
This is unnecessary
Quote:
Originally Posted by Jerry Mcguire View Post
1c) Copy the libraries from lib to lib64
One explanation of why the following is a bad idea --> http://linuxmafia.com/faq/Admin/ld-lib-path.html
Quote:
Originally Posted by Jerry Mcguire View Post
2b) Don't know the purpose, but anyway

export LD_LIBRARY_PATH=/usr/lib64
Changes in red...
Quote:
Originally Posted by Jerry Mcguire View Post
../mpfr-2.4.1/configure --prefix=/usr --libdir=/usr/lib64 --with-gmp-lib=/usr/lib64
Once again, this in unnecessary.
Quote:
Originally Posted by Jerry Mcguire View Post
2d) Copy the libraries from lib to lib64
Changes in red...
Quote:
Originally Posted by Jerry Mcguire View Post
../gcc-4.4.1/configure --prefix=/opt/gcc-4.4.1 --libdir=/opt/gcc-4.4.1/lib64 --libexecdir=/opt/gcc-4.4.1/lib64 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-c99 --enable-long-long --enable-languages=c,c++ --disable-libstdcxx-pch --with-gmp-lib=/usr/lib64 --with-mpfr-lib=/usr/lib64
You'll overwrite your existing compilers if you install in /usr. If you need/want to install another version install it in /opt or /usr/local or in your $HOME.
Quote:
Originally Posted by Jerry Mcguire View Post
/* didn't do make check because it fails without autogen */
Bad idea. Install autogen (which really isn't necessary) or execute
Code:
make -k check 
../gcc-4.4.1/contrib/test_summary | grep -A7 Summ
This will cause the test suite to not stop at errors and present you with a summary of the results. It is very likely that you will get a few unexpected errors from gcc's test suite.

RH does provide g++ as has already been pointed out.
 
Old 08-07-2009, 02:50 AM   #8
Jerry Mcguire
Member
 
Registered: Jul 2009
Location: Hong Kong SAR
Distribution: RedHat, Fedora
Posts: 136

Original Poster
Rep: Reputation: 17
Thanks, all.

I had a working "g++" command on fedora before. Didn't ask where it came from, and thought RH should have it also. It turns out the executable in RH is "g++34" . I have had it all along! Still the learning process is painful but rewarding.
 
Old 08-07-2009, 01:35 PM   #9
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,362

Rep: Reputation: 171Reputation: 171
Quote:
Available Packages
Name : compat-libstdc++-33
Arch : i386
Version : 3.2.3
Release : 61
Size : 232 k
Repo : base
Summary : Compatibility standard C++ libraries
URL : http://gcc.gnu.org
License : GPL
Description: The compat-libstdc++ package contains compatibility standard C++
: library from GCC 3.3.4.
I am going to guess that g++34 is probably using the 3.3.4 C++ libs rather than the newer 4.1/4.3 lib. If it is working for you then I would not worry about it, as I said above for most uses there has been very little added between version. However if you do attempt to use some code that does make use of the newer stuff in 4.1/4.3 it may give you some errors that would be tough to figure out without this information. The compiled code may not be as optimized with the older compiler compatibility (maybe).
 
  


Reply

Tags
g++, gcc


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
Installing GCC blackadder Linux - Software 1 02-04-2005 07:35 AM
help installing gcc krissly1 Linux - Software 4 11-21-2003 07:22 PM
Need help on installing GCC. Jonka Linux - Software 2 11-12-2003 04:12 PM
Installing GCC 3.1 over GCC 2.96...? aaronluke Linux - General 3 09-27-2002 05:28 AM
Installing gcc 3.02 ander45 Linux - Software 1 11-21-2001 05:10 AM


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