Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4141394
  • 博文数量: 447
  • 博客积分: 1241
  • 博客等级: 中尉
  • 技术积分: 5786
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-27 06:48
个人简介

读好书,交益友

文章分类

全部博文(447)

文章存档

2023年(6)

2022年(29)

2021年(49)

2020年(16)

2019年(15)

2018年(23)

2017年(67)

2016年(42)

2015年(51)

2014年(57)

2013年(52)

2012年(35)

2011年(5)

分类: C/C++

2012-10-11 20:13:12

ubuntu安装gcc 4.7,比centos复杂。

 

出现
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
必须要安装mpc, mpfr and gmp.
编译gmp5.05
解压缩gmp5.05
cd  gmp-5.0.5/
mkdir build && cd build
../configure --prefix=/usr/gcc_4_7 –build=x86_64-linux-gnu
make
make install
安装MPFR
cd mpfr-3.1.1/

mkdir build && cd build
../configure --build=x86_64-linux-gnu --prefix=/usr/gcc_4_7 --with-gmp=/usr/gcc_4_7 –with-mpfr=/usr/gcc_4_7
make
sudo make install
安装mpc 0.8.2
cd mpc-0.8.2/

mkdir build && cd build
../configure --build=x86_64-linux-gnu --prefix=/usr/gcc_4_7 --with-gmp=/usr/gcc_4_7 –with-mpfr=/usr/gcc_4_7
make
sudo make install
编译gcc
下载gcc 4.7.1
cd gcc-4.7.1/
mkdir build && cd build

export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
export CPLUS_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
../configure --build=x86_64-linux-gnu --prefix=/usr/gcc_4_7 --with-gmp=/usr/gcc_4_7 --with-mpfr=/usr/gcc_4_7 --with-mpc=/usr/gcc_4_7 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib –program-suffix=-4.7
make
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
sudo make install
加入.bashrc
cd ~
gedit .bashrc
添加
export PATH=/usr/gcc_4_7/bin:$PATH
export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH
export OBJC_INCLUDE_PATH=$C_INCLUDE_PATH
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH

运行
. .bashrc
运行
g++-4.7 –version
显示
g++-4.7 (GCC) 4.7.1

安装成功

新建文件
#include

 

using namespace std;

 

int main() {

     cout << [](int m, int n) { return m + n;} (2,4) << endl;

     return 0;

 }

编译
g++ -std=c++11 main.cpp

经过一阵子的折腾,发现codeblocks和monodevelop 真难用,还是使用eclipse吧

阅读(6256) | 评论(0) | 转发(0) |
0

上一篇:软件架构和编码

下一篇:vc编译openssl

给主人留下些什么吧!~~