Centos安装GCC 4.8.2和boost 1.54.0

Centos安装GCC 4.8.2和boost 1.54.0。

国外有人做了个脚本bld.sh,用起来很舒服:

$ # Download and install it.
$ mkdir /shared/tools/gcc/4.8.2
$ cd /shared/tools/gcc/4.8.2
$ wget http://projects.joelinoff.com/gcc-4.8.2/bld.sh
$ chmod a+x bld.sh
 
$ # Optionally there is also a very simple Makefile.
$ wget http://projects.joelinoff.com/gcc-4.8.2/Makefile
 
$ # bld.sh doesn't check for packages
$ # This is one that I needed.
$ # if not installed you will see a missing gnu/stabs-32.h error late in the process.
$ sudo yum install -y glibc-devel.i686
<output snipped>
 
$ # I also had to install texinfo, you may have to install others.
$ sudo yum install -y texinfo
<output snipped>
 
$ # You can run bld.sh directly or you can simply type "make" if you downloaded
$ # the Makefile.
$ ./bld.sh 2>&1| tee bld.log
安装大约在1个小时左右,如果网速不快,机子性能又不好的话,不建议折腾下去。

下面是个测试文件:

// Simple test program
#include <iostream>
#include <boost/algorithm/string.hpp>
using namespace std;
using namespace boost;
int main()
{
  string s1(" hello world! ");
  cout << "value      : '" << s1 << "'" <<endl;
 
  to_upper(s1);
  cout << "to_upper() : '" << s1 << "'" <<endl;
 
  trim(s1);
  cout << "trim()     : '" << s1 << "'" <<endl;
 
  return 0;
}
编译链接执行如下:

#!/bin/bash
# This script sets the environment to use the newly installed compiler.
# It compiles, links and runs a small test program.
 
# Setup the environment.
MY_GXX_HOME="/shared/tools/gcc/4.8.2/rtf"
export PATH="${MY_GXX_HOME}/bin:${PATH}"
export LD_LIBRARY_PATH="${MY_GXX_HOME}/lib:${LD_LIBRARY_PATH}"
 
# Compile and link.
g++ -O3 -Wall -o test.exe test.cc
 
# Run.
./test.exe
# Expected output
# value      : ' hello world! '
# to_upper() : ' HELLO WORLD! '
# trim()     : 'HELLO WORLD!'

更多的信息请参考: http://joelinoff.com/blog/?p=1003

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值