2013年7月31日 星期三

Install Code::Blocks 12 on CentOS 6.3

Since CodeBlocks can't be installed from YUM, you'll have to resolve the related dependencies yourself.
Here're my steps:

  1. sudo yum -y gtk2-devel wxBase wxGTK
  2. Download C::B from the official site (http://www.codeblocks.org/downloads/26).
    I downloaded version 12.11. codeblocks-12.11-1.el6.x86_64.tar.bz2
  3. Extract downloaded file:
    tar -jxvf codeblocks-12.11-1.el6.x86_64.tar.bz2
  4. You should get codeblocks-12.11-1.el6.x86_64.rpm from the archive. Install it:
    sudo rpm -i codeblocks-12.11-1.el6.x86_64.rpm
  5. Done!
However, you'll find it annoying when debugging C++ console programs. C::B will call xterm to run you program but you should run gnome-terminal in CentOS. The parameter that should be passed to gnome-terminal is different too.
In C::B, go to Settings->Environment settings->General settings->Terminal to launch console programs, set the value to be
 gnome-terminal --disable-factory --hide-menubar -t $TITLE -x  

You still can't break at break point if you are using GDB under version 7.5. Upgrade to GDB 7.5 or higher to resolve this issue.
I installed GDB 7.6 manually because Yum only has GDB 7.2 now.

  1. Download GDB from http://www.gnu.org/software/gdb/download/
  2. tar xvfz gdb-7.6.tar.gz; cd gdb-7.6; ./configure; make; sudo make install

Done.

2013年7月10日 星期三

Install latest gcc/g++ manually

  1. sudo yum -y install gcc-c++
  2. sudo yum -y install gcc-c++ glibc-devel.i686
  3. sudo yum -y install zip
  4. Donwload and extract latest GNU gmp, ex: gmp-5.1.2.tar.gz
    Enter extracted folder
    ./configure --prefix=/usr --exec-prefix=/usr;make;sudo make install
  5. Donwload and extract latest GNU mpfr, ex: mpfr-3.1.2.tar.gz
    Enter extracted folder
    ./configure;make;sudo make install
  6. Donwload and extract latest GNU mpc, ex: mpc-1.0.1.tar.gz
    Enter extracted folder
    ./configure;make;sudo make install
  7. Add the gmp, mpfr, mpc to ld search list:
    Add the following line to /etc/ld.so.conf.d/usr.local.conf
    /usr/local/lib
  8. sudo ldconfig
  9. Donwload and extract latest GNU gcc, ex: gcc-4.8.1.tar.gz
    Enter extracted folder
    ./configure;make;sudo make install
  • Replace make with make -j8 if you have 8 CPU cores. make -j32 if you want to build with 32 threads.
    make gcc will take very long time, you should use as more cores as you can.
  • The SOP is tested under gcc 4.7.x and 4.8.x