Onega

a lot of VC++ posts, a few C# posts, and some miscellaneous stuff

Saturday, April 19, 2014

Use alternative gcc version

Sometimes gcc version of an OS is not up to date, especially when you are working on an OS of several years ago. Fortunately it is quite easy to build latest version on your own.
procedure to build gcc from source code is well documented on this page: http://gcc.gnu.org/wiki/InstallingGCC
tar xzf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2
make
make install

I followed the above steps to build gcc-4.8.2.
[onega@workstation gcc482objdir]$  /home2/onega/src/gcc-4.8.2/configure --prefix=$HOME/gcc-4.8.2 && make && make install

I changed user-config.jam in order to use new gcc to build boost
[onega@workstation boost_1_55_0]$ grep "4.8.2" ./tools/build/v2/user-config.jam
using gcc : 4.8.2 : /home/onega/gcc-4.8.2/bin/g++ : -L/home/onega/gcc-4.8.2/lib -I/home/onega/gcc-4.8.2/include ;

/home2/onega/src/boost_1_55_0/bootstrap.sh --with-toolset=gcc --prefix=$HOME/boost_1_55_0
it will generate /home2/onega/src/boost_1_55_0/project-config.jam
(Some people suggested to modifying project-config.jam, but I didn't find it at first so I changed user-config.jam.)

./b2 --toolset=gcc-4.8.2 --with-date_time --with-thread --with-regex --with-system --with-filesystem --with-program_options install --prefix=$HOME/boost_1_55_0

To use gcc-4.8.2 in CDT
Open project properties window (Alt+Enter)
C/C++ Build->Settings->C++ Compiler->Command: ~/gcc-4.8.2/bin/g++
C/C++ Build->Settings->C++ Linker->Command: ~/gcc-4.8.2/bin/g++

0 Comments:

Post a Comment

<< Home