{"version":"1.0","provider_name":"UCT HPC","provider_url":"https:\/\/ucthpc.uct.ac.za","author_name":"Timothy Carr","author_url":"https:\/\/ucthpc.uct.ac.za\/index.php\/author\/timothy-carr\/","title":"Compiling the latest GCC version 4.8.1 - UCT HPC","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\" data-secret=\"VIQDWmXlzZ\"><a href=\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/\">Compiling the latest GCC version 4.8.1<\/a><\/blockquote><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/embed\/#?secret=VIQDWmXlzZ\" width=\"600\" height=\"338\" title=\"&#8220;Compiling the latest GCC version 4.8.1&#8221; &#8212; UCT HPC\" data-secret=\"VIQDWmXlzZ\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\"><\/iframe><script type=\"text\/javascript\">\n\/*! This file is auto-generated *\/\n!function(c,d){\"use strict\";var e=!1,o=!1;if(d.querySelector)if(c.addEventListener)e=!0;if(c.wp=c.wp||{},c.wp.receiveEmbedMessage);else if(c.wp.receiveEmbedMessage=function(e){var t=e.data;if(!t);else if(!(t.secret||t.message||t.value));else if(\/[^a-zA-Z0-9]\/.test(t.secret));else{for(var r,s,a,i=d.querySelectorAll('iframe[data-secret=\"'+t.secret+'\"]'),n=d.querySelectorAll('blockquote[data-secret=\"'+t.secret+'\"]'),o=new RegExp(\"^https?:$\",\"i\"),l=0;l<n.length;l++)n[l].style.display=\"none\";for(l=0;l<i.length;l++)if(r=i[l],e.source!==r.contentWindow);else{if(r.removeAttribute(\"style\"),\"height\"===t.message){if(1e3<(s=parseInt(t.value,10)))s=1e3;else if(~~s<200)s=200;r.height=s}if(\"link\"===t.message)if(s=d.createElement(\"a\"),a=d.createElement(\"a\"),s.href=r.getAttribute(\"src\"),a.href=t.value,!o.test(a.protocol));else if(a.host===s.host)if(d.activeElement===r)c.top.location.href=t.value}}},e)c.addEventListener(\"message\",c.wp.receiveEmbedMessage,!1),d.addEventListener(\"DOMContentLoaded\",t,!1),c.addEventListener(\"load\",t,!1);function t(){if(o);else{o=!0;for(var e,t,r,s=-1!==navigator.appVersion.indexOf(\"MSIE 10\"),a=!!navigator.userAgent.match(\/Trident.*rv:11\\.\/),i=d.querySelectorAll(\"iframe.wp-embedded-content\"),n=0;n<i.length;n++){if(!(r=(t=i[n]).getAttribute(\"data-secret\")))r=Math.random().toString(36).substr(2,10),t.src+=\"#?secret=\"+r,t.setAttribute(\"data-secret\",r);if(s||a)(e=t.cloneNode(!0)).removeAttribute(\"security\"),t.parentNode.replaceChild(e,t);t.contentWindow.postMessage({message:\"ready\",secret:r},\"*\")}}}}(window,document);\n<\/script>\n","description":"Before we get started we need todo some dependency work :( 1. Download the following applications a directory of your choice. Lets name it, $HOME\/gcc-build. Extract the applications into gcc-build. &nbsp;&nbsp;&nbsp; GCC - http:\/\/gcc.gnu.org\/gcc-4.8\/&nbsp;&nbsp;&nbsp; GMP - http:\/\/gmplib.org&nbsp;&nbsp;&nbsp; MPFR - http:\/\/www.mpfr.org&nbsp;&nbsp;&nbsp; MPC - http:\/\/www.multiprecision.org&nbsp;&nbsp;&nbsp; Binutils - http:\/\/www.gnu.org\/software\/binutils2. Create another directory called \" contrib \" within the gcc-build directory, ending up with $HOME\/gcc-build\/contrib 3. Extract the applications you downloaded into the&nbsp; $HOME\/gcc-build directory. Consider this to be our staging area. Follow the instructions in the order they are listed in as its dependency based. For example, MPFR is dependent on GMP being compiled and installed. Latest versions. &nbsp;&nbsp; GMP:Extract with tar xfvz gmp.tar.gz&nbsp;&nbsp;&nbsp; Create $HOME\/gcc-build\/contrib\/gmpChange into the directory and compile with .\/configure --prefix=$HOME\/gcc-build\/contrib\/gmpmake &amp;&amp; make install &nbsp;&nbsp;&nbsp;&nbsp; MPFR:Extract with tar xfvz mpfr.tar.gzCreate $HOME\/gcc-build\/contrib\/mpfrChange into the directory and compile with .\/configure --prefix=$HOME\/gcc-build\/contrib\/mpfr --with-gmp-build=&lt;directory in which the source is in, the extracted directory and not the binary directory&gt;&nbsp;&nbsp;&nbsp; MPC:Extract with tar xfvz mpc.tar.gzCreate $HOME\/gcc-build\/contrib\/mpcChange into the directory and compile with .\/configure --prefix=$HOME\/gcc-build\/contrib\/mpc --with-gmp=$HOME\/gcc-build\/contrib\/gmp --with-mpfr=$HOME\/gcc-build\/contrib\/mpfrmake &amp;&amp; make install&nbsp;&nbsp;&nbsp;&nbsp; BinUtils:Extract with bunzip binutils &amp;&amp; tar xfv binutils.tarCreate $HOME\/gcc-build\/contrib\/binutils&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Change into the directory and compile with .\/configure --prefix=$HOME\/gcc-build\/contrib\/binutilsmake &amp;&amp; make installmake target_header_dir=$HOME\/gcc-build\/binutils\/include -C libibertyLibrary and Path location updatesNow that we have completed all the dependency requirements its important to update the library paths and system paths. Add the following below to $HOME\/.bashrc ( User specific functions).LD_LIBRARY_PATH=$HOME\/gcc-build\/contrib\/mpc\/lib:$HOME\/contrib\/gcc-build\/mpfr\/lib:$HOME\/gcc-build\/contrib\/gmp\/lib:$HOME\/gcc-build\/contrib\/binutils\/lib:$LD_LIBRARY_PATHCOMPILE_OF=$HOME\/gcc-build\/contrib\/binutils\/binPATH=$COMPILE_OF:$PATHLogout and login to refresh the environment.Compile GCCEarlier you downloaded the latest version of GCC from a mirror site into $HOME\/gcc-build\/ and extracted the contents in there.Create a directory $HOME\/gcc-build\/build and change directory into $HOME\/gcc-build\/build. Notice that we are NOT executing the \".\/configure\" script from within the extracted directory but rather from a build directory. Its extremely important to adhere to this rule.cd $HOME\/gcc-build\/build\"..\/gcc-4.8.1\/configure --prefix=$HOME\/gcc-build\/contrib\/gcc\/ --enable-languages=c,c++ --with-gmp=$HOME\/gcc-build\/contrib\/gmp --with-mpc=$HOME\/gcc-build\/contrib\/mpc\/ --with-mpfr=$HOME\/gcc-build\/contrib\/mpfr\/\"&nbsp; ( NB: notice the importance of the two periods before the configure script )make -j 4 ( This assumes that you would like the compile of GCC to consume 4 CPU processors.make installmake clean ( This will erase all the intermediate files )$HOME\/gcc-build\/contrib\/gcc\/bin\/gcc &ndash;version should give show the correct version.&nbsp;Configure Modules which is a shell environment manager. Great for managing libraries and various versions of software. I have attached the template for GCC 4.8 which can be placed into the \"modulefiles\" directory. &nbsp;#%Module######################&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gcc 4.8.1 module##proc ModulesHelp { } {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts stderr \"Sets up the paths you need to run gcc 4.8.1\"}set sys&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [uname sysname]set base&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/usr\/loca\/software\/gccset version&nbsp;&nbsp;&nbsp;&nbsp; 4.8.1set basepath&nbsp;&nbsp;&nbsp; $baseset modname&nbsp;&nbsp;&nbsp;&nbsp; [module-info name]set modmode&nbsp;&nbsp;&nbsp;&nbsp; [module-info mode]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prepend-path PATH $basepath\/binprepend-path PATH $basepath\/binutils\/binprepend-path LD_LIBRARY_PATH $basepath\/mpfr\/lib prepend-path LD_LIBRARY_PATH $basepath\/mpc\/libprepend-path LD_LIBRARY_PATH $basepath\/gmp\/libprepend-path LD_LIBRARY_PATH $basepath\/binutils\/lib64prepend-path LD_LIBRARY_PATH $basepath\/lib64"}