{"id":821,"date":"2013-07-08T11:18:34","date_gmt":"2013-07-08T09:18:34","guid":{"rendered":"http:\/\/oldblogs.uct.ac.za\/blog\/big-bytes\/2013\/07\/08\/compiling-gcc-4.8.1"},"modified":"2015-09-04T11:40:17","modified_gmt":"2015-09-04T09:40:17","slug":"compiling-the-latest-gcc-version-4-8-1","status":"publish","type":"post","link":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/","title":{"rendered":"Compiling the latest GCC version 4.8.1"},"content":{"rendered":"Before we get started we need to do some dependency work :(<br>\r\n<br>\r\n1. Download the following applications a directory of your choice. Lets name it, $HOME\/gcc-build. Extract the applications into gcc-build.<br>\r\n<br>\r\n<a href=\"http:\/\/gcc.gnu.org\/gcc-4.8\/\">GCC - http:\/\/gcc.gnu.org\/gcc-4.8\/<\/a><br>\r\n<a href=\"http:\/\/gmplib.org\/\">GMP - http:\/\/gmplib.org<\/a><br>\r\n<a href=\"http:\/\/www.mpfr.org\/\">MPFR - http:\/\/www.mpfr.org<\/a><br>\r\n<a href=\"http:\/\/www.multiprecision.org\/\">MPC - http:\/\/www.multiprecision.org<\/a><br>\r\n<a href=\"http:\/\/www.gnu.org\/software\/binutils\">Binutils - http:\/\/www.gnu.org\/software\/binutils<\/a><br>\r\n<br>\r\n2. Create another directory called \" contrib \" within the gcc-build directory, ending up with $HOME\/gcc-build\/contrib<br>\r\n<br>\r\n3. Extract the applications you downloaded into the\u00a0 $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.<br>\r\n<br>\r\n<strong>GMP:<\/strong>\r\n<ul>\r\n\t<li>Extract with tar xfvz gmp.tar.gz<\/li>\r\n\t<li>Create $HOME\/gcc-build\/contrib\/gmp<\/li>\r\n\t<li>Change into the directory and compile with .\/configure --prefix=$HOME\/gcc-build\/contrib\/gmp<\/li>\r\n\t<li>make &amp;&amp; make install<\/li>\r\n<\/ul>\r\n<strong>MPFR:<\/strong>\r\n<ul>\r\n\t<li>Extract with tar xfvz mpfr.tar.gz<\/li>\r\n\t<li>Create $HOME\/gcc-build\/contrib\/mpfr<\/li>\r\n\t<li>Change 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;<\/li>\r\n<\/ul>\r\n<strong> MPC:<\/strong>\r\n<ul>\r\n\t<li>Extract with tar xfvz mpc.tar.gz<\/li>\r\n\t<li>Create $HOME\/gcc-build\/contrib\/mpc<\/li>\r\n\t<li>Change 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\/mpfr<\/li>\r\n\t<li>make &amp;&amp; make install<\/li>\r\n<\/ul>\r\n<strong>BinUtils:<\/strong>\r\n<ul>\r\n\t<li>Extract with bunzip binutils &amp;&amp; tar xfv binutils.tar<\/li>\r\n\t<li>Create $HOME\/gcc-build\/contrib\/binutils<\/li>\r\n\t<li>Change into the directory and compile with .\/configure --prefix=$HOME\/gcc-build\/contrib\/binutils<\/li>\r\n\t<li>make &amp;&amp; make install<\/li>\r\n\t<li>make target_header_dir=$HOME\/gcc-build\/binutils\/include -C libiberty<\/li>\r\n<\/ul>\r\n<strong>Library and Path location updates<\/strong>\r\n<br>\r\nNow 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).<br>\r\n<br>\r\nLD_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_PATH<br>\r\nCOMPILE_OF=$HOME\/gcc-build\/contrib\/binutils\/bin<br>\r\nPATH=$COMPILE_OF:$PATH<br>\r\n<br>\r\nLogout and login to refresh the environment.<br>\r\n<br>\r\n<span style=\"font-size: small;\"><strong>\r\nCompile GCC<\/strong><\/span>\r\n<ul>\r\n\t<li>Earlier you downloaded the latest version of GCC from a mirror site into $HOME\/gcc-build\/ and extracted the contents in there.<\/li>\r\n\t<li>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.<\/li>\r\n\t<li>cd $HOME\/gcc-build\/build<\/li>\r\n\t<li>\"..\/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\/\"\u00a0 ( NB: notice the importance of the two periods before the configure script )<\/li>\r\n\t<li>make -j 4 ( This assumes that you would like the compile of GCC to consume 4 CPU processors.<\/li>\r\n\t<li>make install<\/li>\r\n\t<li>make clean ( This will erase all the intermediate files )<\/li>\r\n\t<li>$HOME\/gcc-build\/contrib\/gcc\/bin\/gcc \u2013version should give show the correct version.<\/li>\r\n<\/ul>\r\n&nbsp;<br>\r\n<br>\r\nConfigure <a title=\"Modules\" href=\"http:\/\/sourceforge.net\/projects\/modules\/\">Modules <\/a>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.<br>\r\n<br>\r\n&nbsp;\r\n<br>\r\n<pre>#%Module##################\r\n##\r\n##\u00a0\u00a0\u00a0\u00a0\u00a0 gcc 4.8.1 module\r\n##\r\nproc ModulesHelp { } {\r\nputs stderr \"Sets up the paths you need to run gcc 4.8.1\"\r\n}\r\n\r\nset sys\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [uname sysname]\r\nset base\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/usr\/loca\/software\/gcc\r\nset version\u00a0\u00a0\u00a0\u00a0 4.8.1\r\nset basepath\u00a0\u00a0\u00a0 $base\r\n\r\nset modname\u00a0\u00a0\u00a0\u00a0 [module-info name]\r\nset modmode\u00a0\u00a0\u00a0\u00a0 [module-info mode]\r\n\r\nprepend-path PATH $basepath\/bin\r\nprepend-path PATH $basepath\/binutils\/bin\r\n\r\nprepend-path LD_LIBRARY_PATH $basepath\/mpfr\/lib\r\nprepend-path LD_LIBRARY_PATH $basepath\/mpc\/lib\r\nprepend-path LD_LIBRARY_PATH $basepath\/gmp\/lib\r\nprepend-path LD_LIBRARY_PATH $basepath\/binutils\/lib64\r\nprepend-path LD_LIBRARY_PATH $basepath\/lib64<br><\/pre>","protected":false},"excerpt":{"rendered":"<p>Before we get started we need todo some dependency work \ud83d\ude41 <\/p>\n<p>1. Download the following applications a directory of your choice. Lets name it, $HOME\/gcc-build. Extract the applications into gcc-build. <\/p>\n<p>&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/gcc.gnu.org\/gcc-4.8\/\">GCC &#8211; http:\/\/gcc.gnu.org\/gcc-4.8\/<\/a><br \/>&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/gmplib.org\/\">GMP &#8211; http:\/\/gmplib.org<\/a><br \/>&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/www.mpfr.org\/\">MPFR &#8211; http:\/\/www.mpfr.org<\/a><br \/>&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/www.multiprecision.org\/\">MPC &#8211; http:\/\/www.multiprecision.org<\/a><br \/>&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/www.gnu.org\/software\/binutils\">Binutils &#8211; http:\/\/www.gnu.org\/software\/binutils<\/a><\/p>\n<p>2. Create another directory called &#8221; contrib &#8221; within the gcc-build directory, ending up with $HOME\/gcc-build\/contrib <\/p>\n<p>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. <\/p>\n<p>&nbsp;&nbsp; <strong>GMP:<\/strong><\/p>\n<ul>\n<li>Extract with tar xfvz gmp.tar.gz&nbsp;&nbsp;&nbsp; <\/li>\n<li>Create $HOME\/gcc-build\/contrib\/gmp<\/li>\n<li>Change into the directory and compile with .\/configure &#8211;prefix=$HOME\/gcc-build\/contrib\/gmp<\/li>\n<li>make &amp;&amp; make install <\/li>\n<\/ul>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; <strong>MPFR:<\/strong><\/p>\n<ul>\n<li>Extract with tar xfvz mpfr.tar.gz<\/li>\n<li>Create $HOME\/gcc-build\/contrib\/mpfr<\/li>\n<li>Change into the directory and compile with .\/configure &#8211;prefix=$HOME\/gcc-build\/contrib\/mpfr &#8211;with-gmp-build=&lt;directory in which the source is in, the extracted directory and not the binary directory&gt;<\/li>\n<\/ul>\n<p>&nbsp;&nbsp;&nbsp;<strong> MPC:<\/strong><\/p>\n<ul>\n<li>Extract with tar xfvz mpc.tar.gz<\/li>\n<li>Create $HOME\/gcc-build\/contrib\/mpc<\/li>\n<li>Change into the directory and compile with .\/configure &#8211;prefix=$HOME\/gcc-build\/contrib\/mpc &#8211;with-gmp=$HOME\/gcc-build\/contrib\/gmp &#8211;with-mpfr=$HOME\/gcc-build\/contrib\/mpfr<\/li>\n<li>make &amp;&amp; make install&nbsp;<\/li>\n<\/ul>\n<p>&nbsp;&nbsp;&nbsp; <strong>BinUtils:<\/strong><\/p>\n<ul>\n<li>Extract with bunzip binutils &amp;&amp; tar xfv binutils.tar<\/li>\n<li>Create $HOME\/gcc-build\/contrib\/binutils&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <\/li>\n<li>Change into the directory and compile with .\/configure &#8211;prefix=$HOME\/gcc-build\/contrib\/binutils<\/li>\n<li>make &amp;&amp; make install<\/li>\n<li>make target_header_dir=$HOME\/gcc-build\/binutils\/include -C libiberty<\/li>\n<\/ul>\n<p><strong>Library and Path location updates<\/strong><\/p>\n<p>Now 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).<\/p>\n<p>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_PATH<br \/>COMPILE_OF=$HOME\/gcc-build\/contrib\/binutils\/bin<br \/>PATH=$COMPILE_OF:$PATH<\/p>\n<p>Logout and login to refresh the environment.<\/p>\n<p><span><strong><br \/>Compile GCC<\/strong><\/span><\/p>\n<ul>\n<li>Earlier you downloaded the latest version of GCC from a mirror site into $HOME\/gcc-build\/ and extracted the contents in there.<\/li>\n<li>Create a directory $HOME\/gcc-build\/build and change directory into $HOME\/gcc-build\/build. Notice that we are NOT executing the &#8220;.\/configure&#8221; script from within the extracted directory but rather from a build directory. Its extremely important to adhere to this rule.<\/li>\n<li>cd $HOME\/gcc-build\/build<\/li>\n<li>&#8220;..\/gcc-4.8.1\/configure &#8211;prefix=$HOME\/gcc-build\/contrib\/gcc\/ &#8211;enable-languages=c,c++ &#8211;with-gmp=$HOME\/gcc-build\/contrib\/gmp &#8211;with-mpc=$HOME\/gcc-build\/contrib\/mpc\/ &#8211;with-mpfr=$HOME\/gcc-build\/contrib\/mpfr\/&#8221;&nbsp; ( NB: notice the importance of the two periods before the configure script )<\/li>\n<li>make -j 4 ( This assumes that you would like the compile of GCC to consume 4 CPU processors.<\/li>\n<li>make install<\/li>\n<li>make clean ( This will erase all the intermediate files )<\/li>\n<li>$HOME\/gcc-build\/contrib\/gcc\/bin\/gcc &ndash;version should give show the correct version.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Configure <a href=\"http:\/\/sourceforge.net\/projects\/modules\/\" title=\"Modules\">Modules <\/a>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 &#8220;modulefiles&#8221; directory. <\/p>\n<p>&nbsp;<\/p>\n<p>#%Module##################<br \/>##<br \/>##&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gcc 4.8.1 module<br \/>##<br \/>proc ModulesHelp { } {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts stderr &#8220;Sets up the paths you need to run gcc 4.8.1&#8221;<br \/>}<\/p>\n<p>set sys&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [uname sysname]<br \/>set base&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/usr\/loca\/software\/gcc<br \/>set version&nbsp;&nbsp;&nbsp;&nbsp; 4.8.1<br \/>set basepath&nbsp;&nbsp;&nbsp; $base<\/p>\n<p>set modname&nbsp;&nbsp;&nbsp;&nbsp; [module-info name]<br \/>set modmode&nbsp;&nbsp;&nbsp;&nbsp; [module-info mode]<br \/>&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; <br \/>prepend-path PATH $basepath\/bin<br \/>prepend-path PATH $basepath\/binutils\/bin<\/p>\n<p>prepend-path LD_LIBRARY_PATH $basepath\/mpfr\/lib <br \/>prepend-path LD_LIBRARY_PATH $basepath\/mpc\/lib<br \/>prepend-path LD_LIBRARY_PATH $basepath\/gmp\/lib<br \/>prepend-path LD_LIBRARY_PATH $basepath\/binutils\/lib64<br \/>prepend-path LD_LIBRARY_PATH $basepath\/lib64<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Compiling the latest GCC version 4.8.1 - UCT HPC<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Compiling the latest GCC version 4.8.1 - UCT HPC\" \/>\n<meta property=\"og:description\" content=\"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 &quot; contrib &quot; 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 &quot;.\/configure&quot; 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&quot;..\/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\/&quot;&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 &quot;modulefiles&quot; directory. &nbsp;#%Module######################&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gcc 4.8.1 module##proc ModulesHelp { } {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts stderr &quot;Sets up the paths you need to run gcc 4.8.1&quot;}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\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/\" \/>\n<meta property=\"og:site_name\" content=\"UCT HPC\" \/>\n<meta property=\"article:published_time\" content=\"2013-07-08T09:18:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-09-04T09:40:17+00:00\" \/>\n<meta name=\"author\" content=\"Timothy Carr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Timothy Carr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/\"},\"author\":{\"name\":\"Timothy Carr\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#\/schema\/person\/41f6cd039836d7741f2b82a7b7cfe8d0\"},\"headline\":\"Compiling the latest GCC version 4.8.1\",\"datePublished\":\"2013-07-08T09:18:34+00:00\",\"dateModified\":\"2015-09-04T09:40:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/\"},\"wordCount\":543,\"publisher\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#organization\"},\"articleSection\":[\"programming\"],\"inLanguage\":\"en-ZA\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/\",\"url\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/\",\"name\":\"Compiling the latest GCC version 4.8.1 - UCT HPC\",\"isPartOf\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#website\"},\"datePublished\":\"2013-07-08T09:18:34+00:00\",\"dateModified\":\"2015-09-04T09:40:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/#breadcrumb\"},\"inLanguage\":\"en-ZA\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ucthpc.uct.ac.za\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Compiling the latest GCC version 4.8.1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#website\",\"url\":\"https:\/\/ucthpc.uct.ac.za\/\",\"name\":\"UCT HPC\",\"description\":\"University of Cape Town High Performance Computing\",\"publisher\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ucthpc.uct.ac.za\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-ZA\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#organization\",\"name\":\"University of Cape Town High Performance Computing\",\"url\":\"https:\/\/ucthpc.uct.ac.za\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-ZA\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/ucthpc.uct.ac.za\/wp-content\/uploads\/2015\/09\/logocircless.png\",\"contentUrl\":\"https:\/\/ucthpc.uct.ac.za\/wp-content\/uploads\/2015\/09\/logocircless.png\",\"width\":450,\"height\":423,\"caption\":\"University of Cape Town High Performance Computing\"},\"image\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#\/schema\/person\/41f6cd039836d7741f2b82a7b7cfe8d0\",\"name\":\"Timothy Carr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-ZA\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7e94dcf3a408e6ada008042fc29d4b15?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7e94dcf3a408e6ada008042fc29d4b15?s=96&d=mm&r=g\",\"caption\":\"Timothy Carr\"},\"sameAs\":[\"http:\/\/ucthpc.uct.ac.za\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Compiling the latest GCC version 4.8.1 - UCT HPC","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/","og_locale":"en_US","og_type":"article","og_title":"Compiling the latest GCC version 4.8.1 - UCT HPC","og_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","og_url":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/","og_site_name":"UCT HPC","article_published_time":"2013-07-08T09:18:34+00:00","article_modified_time":"2015-09-04T09:40:17+00:00","author":"Timothy Carr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Timothy Carr","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/#article","isPartOf":{"@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/"},"author":{"name":"Timothy Carr","@id":"https:\/\/ucthpc.uct.ac.za\/#\/schema\/person\/41f6cd039836d7741f2b82a7b7cfe8d0"},"headline":"Compiling the latest GCC version 4.8.1","datePublished":"2013-07-08T09:18:34+00:00","dateModified":"2015-09-04T09:40:17+00:00","mainEntityOfPage":{"@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/"},"wordCount":543,"publisher":{"@id":"https:\/\/ucthpc.uct.ac.za\/#organization"},"articleSection":["programming"],"inLanguage":"en-ZA"},{"@type":"WebPage","@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/","url":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/","name":"Compiling the latest GCC version 4.8.1 - UCT HPC","isPartOf":{"@id":"https:\/\/ucthpc.uct.ac.za\/#website"},"datePublished":"2013-07-08T09:18:34+00:00","dateModified":"2015-09-04T09:40:17+00:00","breadcrumb":{"@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/#breadcrumb"},"inLanguage":"en-ZA","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/2013\/07\/08\/compiling-the-latest-gcc-version-4-8-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ucthpc.uct.ac.za\/"},{"@type":"ListItem","position":2,"name":"Compiling the latest GCC version 4.8.1"}]},{"@type":"WebSite","@id":"https:\/\/ucthpc.uct.ac.za\/#website","url":"https:\/\/ucthpc.uct.ac.za\/","name":"UCT HPC","description":"University of Cape Town High Performance Computing","publisher":{"@id":"https:\/\/ucthpc.uct.ac.za\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ucthpc.uct.ac.za\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-ZA"},{"@type":"Organization","@id":"https:\/\/ucthpc.uct.ac.za\/#organization","name":"University of Cape Town High Performance Computing","url":"https:\/\/ucthpc.uct.ac.za\/","logo":{"@type":"ImageObject","inLanguage":"en-ZA","@id":"https:\/\/ucthpc.uct.ac.za\/#\/schema\/logo\/image\/","url":"https:\/\/ucthpc.uct.ac.za\/wp-content\/uploads\/2015\/09\/logocircless.png","contentUrl":"https:\/\/ucthpc.uct.ac.za\/wp-content\/uploads\/2015\/09\/logocircless.png","width":450,"height":423,"caption":"University of Cape Town High Performance Computing"},"image":{"@id":"https:\/\/ucthpc.uct.ac.za\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/ucthpc.uct.ac.za\/#\/schema\/person\/41f6cd039836d7741f2b82a7b7cfe8d0","name":"Timothy Carr","image":{"@type":"ImageObject","inLanguage":"en-ZA","@id":"https:\/\/ucthpc.uct.ac.za\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7e94dcf3a408e6ada008042fc29d4b15?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7e94dcf3a408e6ada008042fc29d4b15?s=96&d=mm&r=g","caption":"Timothy Carr"},"sameAs":["http:\/\/ucthpc.uct.ac.za"]}]}},"_links":{"self":[{"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/posts\/821"}],"collection":[{"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/comments?post=821"}],"version-history":[{"count":7,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/posts\/821\/revisions"}],"predecessor-version":[{"id":2431,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/posts\/821\/revisions\/2431"}],"wp:attachment":[{"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/media?parent=821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/categories?post=821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/tags?post=821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}