{"id":642,"date":"2012-03-28T20:34:36","date_gmt":"2012-03-28T20:34:36","guid":{"rendered":"http:\/\/joelinoff.com\/blog\/?p=642"},"modified":"2012-04-02T01:18:45","modified_gmt":"2012-04-02T01:18:45","slug":"bash-script-to-download-build-and-install-gcc-4-6-3-and-boost-1-49","status":"publish","type":"post","link":"https:\/\/joelinoff.com\/blog\/?p=642","title":{"rendered":"Bash script to download, build and install gcc 4.6.3 and boost 1.49"},"content":{"rendered":"<p>I recently had to build gcc 4.6.3 on CentOS 5.5 so I put together <a href=\"http:\/\/projects.joelinoff.com\/gcc-4.6.3\/bld.sh.txt\">this<\/a> script to do all of the work. It is released in text mode so that you can cut-n-paste it from the web page. The shell version is also available: <a href=\"http:\/\/projects.joelinoff.com\/gcc-4.6.3\/bld.sh\">http:\/\/projects.joelinoff.com\/gcc-4.6.3\/bld.sh<\/a> if you want to download it directly using a tool like wget.<\/p>\n<p>The full installation of gcc-4.6.3 and boost-1.49 requires about 4GB of disk space. After the build is complete you can delete the archives, bld and src directory trees to reclaim about 3.4GB of disk space.<br \/>\n<!--more--><\/p>\n<h2>Using bld.sh<\/h2>\n<p>Here is how you might use build script described above to install gcc-4.6.3 and boost-1.49 on your system.<\/p>\n<p>[crayon lang=&#8221;bash&#8221; toolbar=&#8221;always&#8221; title=&#8221;Download, Build and Install&#8221;]<br \/>\n#!\/bin\/bash<br \/>\numask 0<br \/>\nmkdir -p \/shared\/tools\/gcc\/gcc-4.6.3<br \/>\ncd \/shared\/tools\/gcc\/gcc-4.6.3<br \/>\nwget http:\/\/projects.joelinoff.com\/gcc-4.6.3\/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\/\/ Test the gcc 4.6.3 compiler.<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\nThen 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.3\/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\nor if you prefer make...\n\n[crayon lang=\"make\" toolbar=\"always\" title=\"Makefile\"]\nGHM=\"\/home\/jlinoff\/work\/gcc-4.6.3\/rtf\"\nGXX=\"${GHM}\/bin\/g++\" # OR PATH=\"${GHM}\/bin:${PATH}\"\n\nall: x.exe\n\t.\/x.exe\n\nclean:\n\t\\rm -f *~ *exe\n\n%.exe : %.cc\n\t@export LD_LIBRARY_PATH=\"$(GHM)\/lib64\" ; \\\n\t$(GXX) -O3 -Wall -o $@ $<\n[\/crayon]\n\n\n\n<h2>Final Thoughts<\/h2>\n<p>This script has been tested on CentOS 5.5. <\/p>\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.3-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.3 on CentOS 5.5 so I put together this script to do all of the work. It is released 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.3\/bld.sh if you want to download it directly using a tool &hellip; <a href=\"https:\/\/joelinoff.com\/blog\/?p=642\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Bash script to download, build and install gcc 4.6.3 and boost 1.49<\/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,16],"tags":[17],"_links":{"self":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/642"}],"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=642"}],"version-history":[{"count":11,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions"}],"predecessor-version":[{"id":655,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions\/655"}],"wp:attachment":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}