Bash script to install gcc-4.9.2 with boost 1.57 on CentOS 5.x, CentOS 6.x and Mac OS X

This week I created a script to install the gcc-4.9.3 compiler and linker with boost 1.5.7. A very simple Makefile is also available. Both files are based on scripts I have created for earlier versions of the compiler. This version also includes tcmalloc for linux platforms.

This script is also available on github:
https://github.com/jlinoff/gcc-4.9.2-boost-1.57
To use it just download bld.sh and Makefile and type “make” as shown below:

$ # Download the scripts using wget.
$ mkdir /opt/gcc-4.9.2
$ cd /opt/gcc-4.9.2
$ wget http://projects.joelinoff.com/gcc-4.9.2/bld.sh
$ wget http://projects.joelinoff.com/gcc-4.9.2/Makefile
$ chmod a+x bld.sh
$ make
[output snipped]
$ # The compiler is installed in /opt/gcc-4.9.2/rtf/bin

At this point the compiler is installed and you can use it as follows:

$ # Compile, link and run a small test program.
$ # Note that LD_LIBRARY_PATH must be used unless the
$ # compiler is installed in standard place.
$ export PATH="/opt/gcc-4.9.2/bin:${PATH}"
$ export LD_LIBRARY_PATH="/opt/gcc/4.9.2/lib64:/opt/gcc-4.9.2/lib:${LD_LIBRARY_PATH}"
$ cat >test.cc <
using namespace std;
main() {
  cout << "Hello, World!" << endl;
}
EOF
$ g++ -o test.exe -g -Wall test.cc
$ ./test.exe
Hello, World!

Enjoy!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.