The bld.sh script provided installs gcc 4.8.3 and boost 1.55.0 on CentOS 6.x, CentOS 5.x and Mac OS X for testing. It is another entry in my continuing series of releases for different versions of g++. Hopefully this will make it easier for folks that want to experiment with this version of the GNU C++ compiler.
There is also a very simple Makefile: http://projects.joelinoff.com/gcc-4.8.3/Makefile that is not required but that I found useful.
This text version is also available so that you can cut-n-paste from a web page: http://projects.joelinoff.com/gcc-4.8.3/bld.sh.txt.
Please note that this is not a product. It is simply my best attempt to get it working in my development environments. For example, it does not check for packages because I try to build it on different systems that have different package managers (yum, apt, port, etc.). What this means is that if it doesn’t work for you, you will have to do some debugging. If you find a problem, please post a fix in the comment section here so that others can benefit from it.
1 Download and Install It
Here are the steps to download and install it. Root access is not required unless you need to install support packages.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$ # Download and install it. $ mkdir /shared/tools/gcc/4.8.3 $ cd /shared/tools/gcc/4.8.3 $ wget http://projects.joelinoff.com/gcc-4.8.3/bld.sh $ chmod a+x bld.sh $ # Optionally there is also a very simple Makefile. $ wget http://projects.joelinoff.com/gcc-4.8.3/Makefile $ # bld.sh doesn't check for packages $ # This is one that I needed. $ # if not installed you will see a missing gnu/stabs-32.h error late in the process. $ sudo yum install -y glibc-devel.i686 <output snipped> $ # I also had to install texinfo, you may have to install others. $ sudo yum install -y texinfo <output snipped> $ # You can run bld.sh directly or you can simply type "make" if you downloaded $ # the Makefile. $ ./bld.sh 2>&1| tee bld.log |
The build process can take a long time depending on the speed of your CPU(s) and disks. On my test system it took more than 5 hours.
If the process fails it is most likely because packages are missing on the system.
If a problem does occur, install the package, then delete the src and bld directories and try again. If you have installed the option Makefile you can type “make clean” and then “make”.
The rtf (release to field) directory contains the releases for each package.
2 How to Use the Compiler
This section shows how to compile, link and execute a simple program using the newly installed compiler by setting up your environment properly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// Simple test program #include <iostream> #include <boost/algorithm/string.hpp> using namespace std; using namespace boost; int main() { string s1(" hello world! "); cout << "value : '" << s1 << "'" <<endl; to_upper(s1); cout << "to_upper() : '" << s1 << "'" <<endl; trim(s1); cout << "trim() : '" << s1 << "'" <<endl; return 0; } |
You compile, link and run it as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#!/bin/bash # This script sets the environment to use the newly installed compiler. # It compiles, links and runs a small test program. # Setup the environment. MY_GXX_HOME="/shared/tools/gcc/4.8.3/rtf" export PATH="${MY_GXX_HOME}/bin:${PATH}" export LD_LIBRARY_PATH="${MY_GXX_HOME}/lib:${MY_GXX_HOME}/lib64:${LD_LIBRARY_PATH}" export LD_RUN_PATH="${MY_GXX_HOME}/lib:${MY_GXX_HOME}/lib64:${LD_LIBRARY_PATH}" # Compile and link. g++ -O3 -std=c++11 -Wall -o test.exe test.cc # Run. ./test.exe # Expected output # value : ' hello world! ' # to_upper() : ' HELLO WORLD! ' # trim() : 'HELLO WORLD!' |
3 Disk Space Requirements
You will need about 5.5GB to download and build all of the packages. Once the build is finished you can reclaim most of the space because the released files only require about 600 MB. Here is the breakdown:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$ # This was on my Mac $ cd /shared/tools $ du -s -h gcc/4.8.3 5.5G gcc/4.8.3 $ du -s -h gcc/4.8.3/* 187M gcc/4.8.3/archives 2.1G gcc/4.8.3/bld 28K gcc/4.8.3/bld.sh 18M gcc/4.8.3/logs 4.0K gcc/4.8.3/Makefile 595M gcc/4.8.3/rtf 2.6G gcc/4.8.3/src |
Note that the logs directory exists because I used the “make” command instead of running blds.sh directly.
Once it is built you can remove everything except the contents of the rtf directory tree to save disk space.
4 Packages
This is the list of packages that are installed in the release area.
Package | Version | Web Site |
---|---|---|
binutils |
2.24
|
http://ftp.gnu.org/gnu/binutils |
boost |
1.55.0
|
http://sourceforge.net/projects/boost/files/boost |
cloog |
0.18.0
|
http://www.bastoul.net/cloog”>http://www.bastoul.net/cloog |
gcc |
4.8.3
|
http://ftp.gnu.org/gnu/gcc |
gmp |
5.1.3
|
http://gmplib.org/ |
libiconv |
1.14
|
http://ftp.gnu.org/pub/gnu/libiconv |
mpc |
1.0.2
|
http://www.multiprecision.org/mpc |
mpfr |
3.1.2
|
http://www.mpfr.org |
ppl |
1.1
|
http://bugseng.com/products/ppl |
5 Tested Platforms
These are the platforms that I actually tested the installation on.
Distro | Version | Arch | Status | Date | Notes |
---|---|---|---|---|---|
CentOS |
5.5
|
x86_64 | Passed | 2014-06-26 | |
CentOS |
6.3
|
x86_64 | Passed | 2014-06-27 | Had to manually install the glibc_devel.i686 and texinfo packages. |
CentOS |
6.5
|
x86_64 | Passed | 2014-06-26 | Had to manually install the glibc_devel.i686 and texinfo packages. |
MAC OS X |
10.9.3
|
x86_64 | Passed | 2014-06-26 | Used macports for setting up the environment. |
Unfortunately, I do not have the bandwidth to try to get this to work on other distros (even though I have several Ubuntu boxes at hand) but it should be fairly straightforward to port because it does not rely on distro specific package management.
If you port it to another distro, please send me the changes to that I can incorporate them.
Enjoy!
Hello Joe,
thank you for your excellent work.
one observation, in bld.sh, line 313:
ARS=(
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz OK
ftp://ftp.gmplib.org/pub/gmp-5.1.3/gmp-5.1.3.tar.bz2
the ” ftp://ftp.gmplib.org/pub/gmp-5.1.3/gmp-5.1.3.tar.bz2” link
does not currently (@2015/01) work .
So I changed it to
http://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.gz
instead. In this way the script run well till the end.
Sorry, to be more precise, I realise now that with the above link the compilation starts wells but then I end up with the following error
In file included from /usr/include/features.h:385:0,
from /usr/include/stdio.h:28,
from /home/ald/gcc-Compiling-Building/4.8.3/src/gcc-4.8.3/libgcc/../gcc/tsystem.h:87,
from /home/ald/gcc-Compiling-Building/4.8.3/src/gcc-4.8.3/libgcc/libgcc2.c:27:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
# include <gnu/stubs-32.h> ^
compilation terminated.
make[6]: *** [_muldi3.o] Error 1
make[6]: Leaving directory
/home/ald/gcc-Compiling-Building/4.8.3/bld/gcc-4.8.3/x86_64-unknown-linux-gnu/32/libgcc'
/home/ald/gcc-Compiling-Building/4.8.3/bld/gcc-4.8.3/x86_64-unknown-linux-gnu/libgcc'make[5]: *** [multi-do] Error 1
make[5]: Leaving directory
make[4]: *** [all-multi] Error 2
make[4]: Leaving directory
/home/ald/gcc-Compiling-Building/4.8.3/bld/gcc-4.8.3/x86_64-unknown-linux-gnu/libgcc'
/home/ald/gcc-Compiling-Building/4.8.3/bld/gcc-4.8.3'make[3]: *** [all-stage1-target-libgcc] Error 2
make[3]: Leaving directory
make[2]: *** [stage1-bubble] Error 2
make[2]: Leaving directory
/home/ald/gcc-Compiling-Building/4.8.3/bld/gcc-4.8.3'
/home/ald/gcc-Compiling-Building/4.8.3/bld/gcc-4.8.3'make[1]: *** [all] Error 2
make[1]: Leaving directory
STATUS = 2
probably due to some missing library on my system. So I correct my previous post: certainly the link has to be updated, probably with http://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.bz2
by the way the above error
fatal error: gnu/stubs-32.h: No such file or directory
was due to the missing 32 bit libc dev package on my workstation.After doing :
yum install glibc-devel.i686
the error disappears and the compilation succeeds with no errors. Therefore I can confirm : in the bld.sh script instead of
ftp://ftp.gmplib.org/pub/gmp-5.1.3/gmp-5.1.3.tar.bz2
use :
http://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.bz2
and all will work smooth and nicely.