{"id":811,"date":"2012-09-22T16:11:58","date_gmt":"2012-09-22T16:11:58","guid":{"rendered":"http:\/\/joelinoff.com\/blog\/?p=811"},"modified":"2014-06-28T08:21:24","modified_gmt":"2014-06-28T15:21:24","slug":"bash-script-to-install-gcc-4-7-2-and-boost-1-51-0-on-centos-5-5-and-6-3","status":"publish","type":"post","link":"https:\/\/joelinoff.com\/blog\/?p=811","title":{"rendered":"Bash script to install gcc 4.7.2 and boost 1.51.0 on CentOS 5.5+ and 6.3"},"content":{"rendered":"<p>I recently installed gcc 4.7.2 and boost 1.51.0 on CentOS 5.5, 5.8 and 6.3 to take advantage of the improved support for C++-11. It was painful to do manually so I automated the process with this script: <a title=\"http:\/\/projects.joelinoff.com\/gcc-4.7.2\/bld.sh\" href=\"http:\/\/projects.joelinoff.com\/gcc-4.7.2\/bld.sh\">http:\/\/projects.joelinoff.com\/gcc-4.7.2\/bld.sh<\/a>. Hopefully this will make it easier for folks that want to experiment with the latest version of the GNU C++ compiler.<\/p>\n<div style=\"margin-left: 20px; margin-right: 20px; padding: 5px; background: #ffffdb;\">\nIf you are interested in a more recent version, I recently added a <a href=\"http:\/\/joelinoff.com\/blog\/?p=1514\" title=\"post\">post<\/a> that provides a script to install gcc-4.8.3 and boost 1.55.0.\n<\/div>\n<p><!--more--><br \/>\nThis text version is also available so that you can cut-n-paste from a web page: <a title=\"http:\/\/projects.joelinoff.com\/gcc-4.7.2\/bld.sh.txt\" href=\"http:\/\/projects.joelinoff.com\/gcc-4.7.2\/bld.sh.txt\">http:\/\/projects.joelinoff.com\/gcc-4.7.2\/bld.sh.txt<\/a>. <\/p>\n<h2>1 Download and Install It<\/h2>\n<p>Here are the steps to download and install it. Root access is not required unless you need to install support packages.<\/p>\n<p>[crayon lang=&#8221;bash&#8221; toolbar=&#8221;always&#8221; title=&#8221;Download and Install&#8221;]<br \/>\n$ get-platform.sh<br \/>\nlinux-centos-6.3-x86_64<br \/>\n$ # Download and install it.<br \/>\n$ mkdir \/shared\/tools\/gcc\/4.7.2<br \/>\n$ cd \/shared\/tools\/gcc\/4.7.2<br \/>\n$ wget http:\/\/projects.joelinoff.com\/gcc-4.7.2\/bld.sh<br \/>\n$ chmod a+x bld.sh<br \/>\n$ # configure doesn&#8217;t check for this,<br \/>\n$ # if not installed you will see: missing stabs-32.h<br \/>\n$ sudo yum install -y glibc-devel.i686<br \/>\n<output snipped><br \/>\n$ .\/bld.sh  &#038;>bld.log<br \/>\n[\/crayon]<\/p>\n<p>The build process can take a long time depending on the speed of your CPU(s) and disks. On my test systems it took more than 4 hours.<\/p>\n<p>The rtf (release to field) directory contains the releases for each package.<\/p>\n<h2>2 Use It<\/h2>\n<p>This section shows how to compile, link and execute a simple program using the newly installed compiler by setting up your environment properly.<\/p>\n<p>[crayon lang=&#8221;c++&#8221; toolbar=&#8221;always&#8221; title=&#8221;test.cc&#8221;]<br \/>\n\/\/ Simple test program<br \/>\n#include <iostream><br \/>\n#include <boost\/algorithm\/string.hpp><br \/>\nusing namespace std;<br \/>\nusing namespace boost;<br \/>\nint main()<br \/>\n{<br \/>\n  string s1(&#8221; hello world! &#8220;);<br \/>\n  cout << \"value      : '\" << s1 << \"'\" <<endl;\n\n  to_upper(s1);\n  cout << \"to_upper() : '\" << s1 << \"'\" <<endl;\n\n  trim(s1);\n  cout << \"trim()     : '\" << s1 << \"'\" <<endl;\n\n  return 0;\n}\n[\/crayon]\n\nYou compile, link and run it as follows:\n\n[crayon lang=\"bash\" toolbar=\"always\" title=\"Compile, Link and Run\"]\n#!\/bin\/bash\n# This script sets the environment to use the newly installed compiler.\n# It compiles, links and runs a small test program.\n\n# Setup the environment.\nMY_GXX_HOME=\"\/shared\/tools\/gcc\/4.7.2\/rtf\"\nexport PATH=\"${MY_GXX_HOME}\/bin:${PATH}\"\nexport LD_LIBRARY_PATH=\"${MY_GXX_HOME}\/lib:${LD_LIBRARY_PATH}\"\n\n# Compile and link.\ng++ -O3 -Wall -o test.exe test.cc\n\n# Run.\n.\/test.exe\n# Expected output\n# value      : ' hello world! '\n# to_upper() : ' HELLO WORLD! '\n# trim()     : 'HELLO WORLD!'\n[\/crayon]\n\n\n\n<h2>3 Disk Space Requirements<\/h2>\n<p>You will need about 8GB 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 1 GB. Here is the breakdown:<\/p>\n<p>[crayon lang=&#8221;bash&#8221; toolbar=&#8221;always&#8221; title=&#8221;Disk Space Used&#8221;]<br \/>\n$ cd \/shared\/tools\/gcc<br \/>\n$ du -s -h 4.7.2<br \/>\n8.1G    4.7.2<br \/>\n$ du -s -h 4.7.2\/*<br \/>\n147M    4.7.2\/archives<br \/>\n5.3G    4.7.2\/bld<br \/>\n14M     4.7.2\/bld.log<br \/>\n16K     4.7.2\/bld.sh<br \/>\n1.1G    4.7.2\/rtf<br \/>\n1.7G    4.7.2\/src<br \/>\n[\/crayon]<\/p>\n<h2>4 Packages<\/h2>\n<p>This is the list of packages that are installed in the release area.<\/p>\n<table>\n<thead>\n<tr>\n<th>Package<\/th>\n<th>Version<\/th>\n<th>Web Site<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>binutils<\/td>\n<td>\n<div style=\"text-align:right;\">2.22<\/div>\n<\/td>\n<td><a href=\"http:\/\/ftp.gnu.org\/gnu\/binutils\">http:\/\/ftp.gnu.org\/gnu\/binutils<\/a><\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>boost<\/td>\n<td>\n<div style=\"text-align:right;\">1.51.0<\/div>\n<\/td>\n<td><a href=\"http:\/\/sourceforge.net\/projects\/boost\/files\/boost\">http:\/\/sourceforge.net\/projects\/boost\/files\/boost<\/a><\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>cloog<\/td>\n<td>\n<div style=\"text-align:right;\">0.17<\/div>\n<\/td>\n<td><a href=\"http:\/\/www.bastoul.net\/cloog\">http:\/\/www.bastoul.net\/cloog&#8221;>http:\/\/www.bastoul.net\/cloog<\/a><\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>gcc<\/td>\n<td>\n<div style=\"text-align:right;\">4.7.2<\/div>\n<\/td>\n<td><a href=\"http:\/\/ftp.gnu.org\/gnu\/gcc\">http:\/\/ftp.gnu.org\/gnu\/gcc<\/a><\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>gmp<\/td>\n<td>\n<div style=\"text-align:right;\">5.0.5<\/div>\n<\/td>\n<td><a href=\"http:\/\/gmplib.org\/\">http:\/\/gmplib.org\/<\/a><\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>libiconv<\/td>\n<td>\n<div style=\"text-align:right;\">1.14<\/div>\n<\/td>\n<td><a href=\"http:\/\/ftp.gnu.org\/pub\/gnu\/libiconv\">http:\/\/ftp.gnu.org\/pub\/gnu\/libiconv<\/a><\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>mpc<\/td>\n<td>\n<div style=\"text-align:right;\">1.0<\/div>\n<\/td>\n<td><a href=\"http:\/\/www.multiprecision.org\/mpc\">http:\/\/www.multiprecision.org\/mpc<\/a><\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>mpfr<\/td>\n<td>\n<div style=\"text-align:right;\">3.1.1<\/div>\n<\/td>\n<td><a href=\"http:\/\/www.mpfr.org\">http:\/\/www.mpfr.org<\/a><\/td>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>ppl<\/td>\n<td>\n<div style=\"text-align:right;\">1.0<\/div>\n<\/td>\n<td><a href=\"http:\/\/bugseng.com\/products\/ppl\">http:\/\/bugseng.com\/products\/ppl<\/a><\/td>\n<td>Not recognized by gcc which looks for 0.11 or later.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>5 Tested Platforms<\/h2>\n<p>These are the platforms that I actually tested the installation on.<\/p>\n<table>\n<thead>\n<tr>\n<th>Distro<\/th>\n<th>Version<\/th>\n<th>Arch<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>CentOS<\/td>\n<td>\n<div style=\"text-align:right;\">6.3<\/div>\n<\/td>\n<td>x86_64<\/td>\n<td>Had to manually install the glibc_devel.i686 package.<\/td>\n<\/tr>\n<tr>\n<td>CentOS<\/td>\n<td>\n<div style=\"text-align:right;\">5.8<\/div>\n<\/td>\n<td>x86_64<\/td>\n<td>Worked out of the box.<\/td>\n<\/tr>\n<tr>\n<td>CentOS<\/td>\n<td>\n<div style=\"text-align:right;\">5.5<\/div>\n<\/td>\n<td>x86_64<\/td>\n<td>Worked out of the box.<\/td>\n<\/tr>\n<tr>\n<td>CentOS<\/td>\n<td>\n<div style=\"text-align:right;\">5.2<\/div>\n<\/td>\n<td>x86_64<\/td>\n<td>Verified 2012\/09\/26 by <i>quentin<\/i>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Unfortunately, I do not have the bandwidth to try to get this to work on other distros but it should be fairly straightforward to port because it does not rely on distro specific package management. <\/p>\n<p>If you port it to another distro, please send me the changes to that I can incorporate them.<\/p>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently installed gcc 4.7.2 and boost 1.51.0 on CentOS 5.5, 5.8 and 6.3 to take advantage of the improved support for C++-11. It was painful to do manually so I automated the process with this script: http:\/\/projects.joelinoff.com\/gcc-4.7.2\/bld.sh. Hopefully this will make it easier for folks that want to experiment with the latest version of &hellip; <a href=\"https:\/\/joelinoff.com\/blog\/?p=811\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Bash script to install gcc 4.7.2 and boost 1.51.0 on CentOS 5.5+ and 6.3<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[5],"tags":[23,22],"_links":{"self":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/811"}],"collection":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=811"}],"version-history":[{"count":36,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/811\/revisions"}],"predecessor-version":[{"id":1524,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/811\/revisions\/1524"}],"wp:attachment":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}