CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了centos 6 install gcc-c++大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

前言 问题出现nodejs 环境,在初始安装nodejs相关依赖时,出现gcc-c++ 版本错误 In file included from ../src/bcrypt_node.cc:1: ../../nan/nan.h:47:3: error: #error This version of node/NAN/v8 requires a C++11 compiler In file includ
前言

问题出现nodejs 环境,在初始安装nodejs相关依赖时,出现gcc-c++ 版本错误

In file included from ../src/bcrypt_node.cc:1:
../../nan/nan.h:47:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/memory

查阅资料得知
由于node4.0版本后升级了v8引擎,编译时需要gcc4.8以上版本,Centos6自带的gcc为gcc-4.4.7,不支持编译所需的C++11标准,所以只好升级gcc

版本升级方案

centos6 最新的gcc版本仍停留在4.4.7,不符合要求,这时想到的就是编译安装gcc-c++ ,但在尝试通过rpm升级gcc-c++的过程中发现其和系统基础库有和多依赖
这种对系统层面会产生严重未知影响的升级,能避免还是尽量便面的好
继续参阅资料后发现,可使用devtoolset 工具在系统间使用多个版本gcc-c++

安装devtoolset

  1. 首先安装源
    yum install centos-release-scl-rh centos-release-scl
    yum check-update
  2. 安装devtoolset
    这里不必安装全部的devtoolset ,只需要安装devtoolset-gcc-c++即可
    要注意,安装前要先确认devtoolset 完整包名
    yum search devtoolset

    会得到类似如下结果:

    devtoolset-6.x86_64 : Package that installs devtoolset-6
    devtoolset-7.x86_64 : Package that installs devtoolset-7
    devtoolset-6-gcc.x86_64 : GCC version 6
    devtoolset-6-gcc-c++.x86_64 : C++ support for GCC version 6
    devtoolset-7-gcc.x86_64 : GCC version 7
    devtoolset-7-gcc-c++.x86_64 : C++ support for GCC version 7

这里使用devtoolset-6-gcc-c++

yum install devtoolset-6-gcc-c++

当前sHell启用devtoolset-6-gcc-c++,如想认启用,将此行加入到/etc/profile内即可

source /opt/rh/devtoolset-6/enable

再次编译nodejs依赖,问题顺利解决

后话

当无法顺利升级到高版本时,可以尝试是否有多版本共存或替代的方法

大佬总结

以上是大佬教程为你收集整理的centos 6 install gcc-c++全部内容,希望文章能够帮你解决centos 6 install gcc-c++所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。