电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 1713 人浏览分享

CentOS 6.4 使用C++11

[复制链接]
1713 0

CentOS 6.4 使用C++11,需要安装 devtools2

1.下载 repo 到本地

  1. wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
复制代码


2.安装

  1. yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
复制代码


3.创建链接

  1. ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/
复制代码


4.设置优先级

  1. update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc 100
  2. update-alternatives --install /usr/bin/g++ g++ /usr/local/bin/g++ 100
复制代码


5.或者用下面的方法启用

  1. echo 'source /opt/centos/devtoolset-1.1/enable' >> /etc/profile
  2. source /opt/centos/devtoolset-1.1/enable
复制代码


其中 3,4,5是保证生效,任选一个应该都可以,我依次做了三个。  还有其它生效方法,如:

  1. scl enable devtoolset-2 bash

  2. In your .bash_profile , add at the bottom:
  3. echo "WARNING: devtoolset-2 is enabled!"
  4. . /opt/rh/devtoolset-2/enable
复制代码


可以新打开一个终端,gcc -v 和 g++ -v 来查看版本变化

  1. [me@localhost ~]$ gcc -v
  2. Using built-in specs.
  3. COLLECT_GCC=gcc
  4. COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
  5. Target: x86_64-redhat-linux
  6. Configured with: ../configure --prefix=/opt/rh/devtoolset-2/root/usr --mandir=/opt/rh/devtoolset-2/root/usr/share/man --infodir=/opt/rh/devtoolset-2/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,fortran,lto --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-isl=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/isl-install --with-cloog=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/cloog-install --with-mpc=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
  7. Thread model: posix
  8. gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)

  9. [me@localhost ~]$ g++ -v
  10. Using built-in specs.
  11. COLLECT_GCC=g++
  12. COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
  13. Target: x86_64-redhat-linux
  14. Configured with: ../configure --prefix=/opt/rh/devtoolset-2/root/usr --mandir=/opt/rh/devtoolset-2/root/usr/share/man --infodir=/opt/rh/devtoolset-2/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,fortran,lto --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-isl=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/isl-install --with-cloog=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/cloog-install --with-mpc=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
  15. Thread model: posix
  16. gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
复制代码



您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

0

粉丝

9021

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.