centos安装devtoolset-3支持gcc 4.9.2
2015-08-20 00:00
1321 查看
摘要: centos安装devtoolset-3支持gcc 4.9.2从而支持C++11的regex
由于gcc 4.8.2不支持C++11的regex库,故需升到4.9.2
首先加载源,导入rpm
#centos6系列
#centos7系统
接下来开始下载安装
安装完毕后可通过
启用开发环境
通过gcc -v确认
简单的测试例子
保存成test.cpp
生成
运行
打印出
可正常运行C++11的正则库
由于gcc 4.8.2不支持C++11的regex库,故需升到4.9.2
首先加载源,导入rpm
#centos6系列
wget https://www.softwarecollections.org/repos/rhscl/devtoolset-3/epel-6-x86_64/noarch/rhscl-devtoolset-3-epel-6-x86_64-1-2.noarch.rpm rpm -ivh rhscl-devtoolset-3-epel-6-x86_64-1-2.noarch.rpm
#centos7系统
wget https://www.softwarecollections.org/repos/rhscl/devtoolset-3/epel-7-x86_64/noarch/rhscl-devtoolset-3-epel-7-x86_64-1-2.noarch.rpm rpm -ivh rhscl-devtoolset-3-epel-7-x86_64-1-2.noarch.rpm
接下来开始下载安装
yum install devtoolset-3-toolchain
安装完毕后可通过
scl enable devtoolset-3 bash
启用开发环境
通过gcc -v确认
简单的测试例子
#include <string> #include <regex> #include <stdio.h> int main() { std::string r("(0x[\\dA-Fa-f]+)"); std::regex pattern(r); std::match_results<std::string::const_iterator> result; std::string source = "0x123fd"; bool valid = std::regex_match(source, result, pattern); if (!valid) { printf("no vaild"); return 0; } printf("match result is %s", result[1].str().c_str()); return 0; }
保存成test.cpp
生成
g++ -o test test.cpp -std=c++11
运行
./test
打印出
match result is 0x123fd
可正常运行C++11的正则库
相关文章推荐
- Centos6 编译安装Python
- 硬盘安装CentOS 6.2以及添加GRUB启动菜单
- CentOS 6.2实战部署Nginx+MySQL+PHP
- CentOS 7系统配置上的变化解析
- CentOS下DB2数据库安装过程详解
- CentOS 6.3下编译安装Ruby 2.0笔记
- 在Centos 5.5 上编译安装mysql 5.5.9
- CentOS 6.5源码安装Erlang教程
- centos 5.6 升级php到5.3的方法
- CentOS mysql安装系统方法
- centos下安装mysql服务器的方法
- CentOS 5.1 4.6最新官方下载地址列表
- Centos搭建GTK+Codeblock完整版
- CentOS 5.1下跑Mono和Asp.net的实现方法
- centos 安装免费控制面板kloxo步骤
- CentOS服务器+监控宝SNMP监控全攻略分享
- Centos 5下配置https服务器的方法
- centos 5.1下的安全设置(适合所有的linux版本)