CentOS 6.4 uses C ++ 11

Source: Internet
Author: User

CentOS 6.4 uses C ++ 11

CentOS 6.4 uses C ++ 11 and devtools2 needs to be installed.

1. Download the repo to your local device.

wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo

2. Installation

yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

3. Create a link

ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/

4. Set priority

update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc 100update-alternatives --install /usr/bin/g++ g++ /usr/local/bin/g++ 100

5. Or use the following method to enable

echo 'source /opt/centos/devtoolset-1.1/enable' >> /etc/profile source /opt/centos/devtoolset-1.1/enable

Among them, 3, 4, and 5 are guaranteed to take effect. You can choose either of them. I made three in sequence. There are other effective methods, such:

scl enable devtoolset-2 bashIn your .bash_profile , add at the bottom:echo "WARNING: devtoolset-2 is enabled!". /opt/rh/devtoolset-2/enable

You can open a new terminal, gcc-v and g ++-v to view version changes.

[me@localhost ~]$ gcc -vUsing built-in specs.COLLECT_GCC=gccCOLLECT_LTO_WRAPPER=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapperTarget: x86_64-redhat-linuxConfigured 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-linuxThread model: posixgcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC) [me@localhost ~]$ g++ -vUsing built-in specs.COLLECT_GCC=g++COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapperTarget: x86_64-redhat-linuxConfigured 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-linuxThread model: posixgcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC) 

Reference: [1] http://blog.csdn.net/superye1983/article/details/48263811 [2] https://people.centos.org/tru/devtools-2/readme [3] http://qgjie456.blog.163.com/blog/static/354513672014773716756/ [4] http://blog.csdn.net/dqjyong/article/details/20474883 [5] http://hiltmon.com/blog/2015/08/09/c-plus-plus-11-on-centos-6-dot-6/ [6] http://www.tuicool.com/articles/7JrMJzj

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.