{"id":108,"date":"2012-02-02T02:30:07","date_gmt":"2012-02-02T02:30:07","guid":{"rendered":"http:\/\/joelinoff.com\/blog\/?p=108"},"modified":"2012-04-02T01:19:09","modified_gmt":"2012-04-02T01:19:09","slug":"bash-script-to-download-build-and-install-gcc-4-6-2-boost-1-48","status":"publish","type":"post","link":"https:\/\/joelinoff.com\/blog\/?p=108","title":{"rendered":"Bash script to download, build and install gcc 4.6.2 and boost 1.48"},"content":{"rendered":"<p>I recently had to build gcc 4.6.2 on CentOS 5.5 and found it to be quite painful so I put together this script to do all of the work: <a title=\"http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh.txt\" href=\"http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh.txt\">http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh.txt<\/a>. I am releasing it in text mode so that you can cut-n-paste it from the web page.<\/p>\n<p>The shell version is also available: <a title=\"http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh\" href=\"http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh\">http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh<\/a> if you want to download it directly using something like wget.<br \/>\n<!--more--><\/p>\n<h2>Disk Space Usage<\/h2>\n<p>Beware that building gcc-4.6.2 and boost-1.48 requires almost 4 GB of disk space. Here is the breakdown:<\/p>\n<p>[crayon lang=&#8221;bash&#8221; toolbar=&#8221;always&#8221; title=&#8221;Disk Space Used&#8221;]<br \/>\n% du -s -h gcc-4.6.2\/*<br \/>\n147M    gcc-4.6.2\/archives<br \/>\n572M    gcc-4.6.2\/rtf<br \/>\n3.2G    gcc-4.6.2\/src<br \/>\n% du -s -h gcc-4.6.2\/src\/*<br \/>\n602M    gcc-4.6.2\/src\/boost_1_48_0<br \/>\n25M     gcc-4.6.2\/src\/cloog-0.17.0<br \/>\n2.1G    gcc-4.6.2\/src\/gcc-4.6.2<br \/>\n22M     gcc-4.6.2\/src\/gmp-5.0.3<br \/>\n30M     gcc-4.6.2\/src\/libiconv-1.14<br \/>\n133K    gcc-4.6.2\/src\/LOCAL-TEST<br \/>\n4.5M    gcc-4.6.2\/src\/mpc-0.9<br \/>\n14M     gcc-4.6.2\/src\/mpfr-3.1.0<br \/>\n481M    gcc-4.6.2\/src\/ppl-0.11.2<br \/>\n[\/crayon]<\/p>\n<p>After the build is complete you can delete the archives and src directory trees to reclaim about 3.3GB of disk space.<\/p>\n<h2>Using bld.sh<\/h2>\n<p>Here is how you might use build script described above to install gcc-4.6.2 and boost-1.48 on your system.<\/p>\n<p>[crayon lang=&#8221;bash&#8221; toolbar=&#8221;always&#8221; title=&#8221;Build gcc-4.6.2 and boost-1.48&#8243;]<br \/>\n#!\/bin\/bash<br \/>\numask 0<br \/>\nmkdir -p \/shared\/tools\/gcc\/gcc-4.6.2<br \/>\ncd \/shared\/tools\/gcc\/gcc-4.6.2<br \/>\nwget http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh<br \/>\nchmod a+x bld.sh<br \/>\n.\/bld.sh 2>&#038;1 | tee bld.log<br \/>\n[\/crayon]<\/p>\n<h2>Simple Test Program: x.cc<\/h2>\n<p>If you want, you can create a simple program like this:<\/p>\n<p>[crayon lang=&#8221;c++&#8221; toolbar=&#8221;always&#8221; title=&#8221;Simple Test Program &#8211; x.cc&#8221;]<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\nAnd then compile, link and run it as follows.\n\n[crayon lang=\"bash\" toolbar=\"always\" title=\"Compile, Link and Run\"]\n#!\/bin\/bash\nGHM=\"\/shared\/tools\/gcc\/gcc-4.6.2\/rtf\"\nGXX=\"${GHM}\/bin\/g++\"   # OR PATH=\"${GHM}\/bin:${PATH}\"\nexport LD_LIBRARY_PATH=\"${GHM}\/lib64\"\n$GXX -O3 -Wall -o x.exe x.cc\n.\/x.exe\n# Expected output\n# value      : ' hello world! '\n# to_upper() : ' HELLO WORLD! '\n# trim()     : 'HELLO WORLD!'\n[\/crayon]\n\n\n\n<h2>Final Thoughts<\/h2>\n<p>This script has been tested on CentOS 5.5 (x86_64). <\/p>\n<p>I am in the process of testing it on Ubuntu 11.10 (x86_64). <\/p>\n<blockquote><p>UPDATE #1<br \/>The Ubuntu 11.10 build failed during the stage1 compilation of gcc because it could not find bits\/predefs.h. That file is available under \/usr\/include\/x86_64-linux-gnu so I expect that it would fairly easy to fix this by adding -I\/usr\/include\/x86_64-linux-gnu to the command line using CPPFLAGS. I will try that and post an update.<\/p><\/blockquote>\n<p>Note that I decided to use the latest version CLooG (0.17.0) so I had to put in a small hack to fix the gcc\/g++ source code. Specifically I had to change LANGUAGE_C to CLOOG_LANGUAGE_C in the &lt;gcc-4.6.2-source&gt;\/gcc\/graphite-clast-to-gimple.c to track the same change in CLooG. This hack is done automatically by the script. I also had to turn off version checking because it specifically requires 0.16.0.<\/p>\n<p>Please report problems or suggestions via the comments section.<\/p>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently had to build gcc 4.6.2 on CentOS 5.5 and found it to be quite painful so I put together this script to do all of the work: http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh.txt. I am releasing it in text mode so that you can cut-n-paste it from the web page. The shell version is also available: http:\/\/projects.joelinoff.com\/gcc-4.6.2\/bld.sh if &hellip; <a href=\"https:\/\/joelinoff.com\/blog\/?p=108\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Bash script to download, build and install gcc 4.6.2 and boost 1.48<\/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":[15,5],"tags":[18],"_links":{"self":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/108"}],"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=108"}],"version-history":[{"count":43,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":656,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions\/656"}],"wp:attachment":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}