C++14 standard requested but CXX14 is not defined

文章描述了在CentOS系统上安装R包时遇到的C++14标准未定义的错误。作者尝试了修改.Rprofile的Makevars文件,以及升级GCC至devtoolset-10,但问题仍未解决。最终,通过指定新版本GCC的路径成功解决了问题,强调了升级GCC和明确编译器路径的重要性。

Zhongxu blog

C++14 standard requested but CXX14 is not defined

2021-09-09 

 Default Category

文章目录

在安装R包的时候遇到报错,C++14 standard requested but CXX14 is not defined

查了很多办法,刚开始是根据https://github.com/stan-dev/rstan/issues/892修改.R下面的Makevars,

但是包另外一个错g++: error: unrecognized command line option ‘-std=c++14’

于是继续查到c++1y这个问题,但依然没有解决问题。

复盘了一下,感觉是gcc的问题,所以升级了最新的gcc

1
2
3
4
# 系统是CentOS
sudo yum install centos-release-scl
sudo yum install devtoolset-10
scl enable devtoolset-10 bash

但是装包的时候新版的gcc依然不能别识别,所以修改Makevars,最终用了如下的配置,重点是指定了新版的g++和c++的路径,这样问题就解决了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
MAKEFLAGS = -j18

## C++ flags
CXX=g++
CXX11=g++
CXX14=/opt/rh/devtoolset-9/root/usr/bin/g++
CXX17=g++

CXXFLAGS=-O3 -march=native -Wno-ignored-attributes
CXX11FLAGS=-O3 -march=native -Wno-ignored-attributes
CXX14FLAGS=-O3 -march=native -Wno-ignored-attributes
CXX17FLAGS=-O3 -march=native -Wno-ignored-attributes

CXXPICFLAGS=-fPIC
CXX11PICFLAGS=-fPIC
CXX14PICFLAGS=-fPIC
CXX17PICFLAGS=-fPIC

CXX11STD=-std=c++11
CXX14STD=-std=c++14
CXX17STD=-std=c++17

## C flags
CC=/opt/rh/devtoolset-10/root/usr/bin/gcc
FLAGS=-O3 -march=native

## Fortran flags
FC=gfortran
F77=gfortran
FFLAGS=-O3 -march=native
FCFLAGS=-O3 -march=native

总结: 1,upgrade gcc

2, specify the absolute gcc and g++ path

如果可以的话,建议把整个系统的gcc都替换成新版的

####################################################################

#版权所有 转载请告知 版权归作者所有 如有侵权 一经发现 必将追究其法律责任

#Author: Jason

#####################################################################

文章作者 zzx

来源

C++14 standard requested but CXX14 is not defined - Zhongxu blog

上次更新 2021-09-09

Linux

 肿瘤免疫表型-cold (excluded, desert) and hotTake only memories, leave only footprints 

  

由 Hugo 强力驱动 | 主题 - Even© 2012 - 2023zzx浙ICP备2022010110号 |浙公网安备 33010502007012号

 

### 解决 `ERROR in myResolver is not defined` 错误 `ERROR in myResolver is not defined` 错误通常表示在代码里使用了 `myResolver`,但它并未被定义。下面是一些可能的解决办法: #### 1. 检查变量定义 要保证 `myResolver` 已经被正确定义。例如,若 `myResolver` 是一个函数,需确保函数已经被声明: ```javascript // 定义 myResolver 函数 function myResolver() { // 函数逻辑 } // 使用 myResolver myResolver(); ``` #### 2. 检查模块导入 如果 `myResolver` 是从其他模块导入的,要确保导入语句正确,且该模块确实导出了 `myResolver`。比如: ```javascript // 在 module.js 中导出 myResolver // module.js export function myResolver() { // 函数逻辑 } // 在 main.js 中导入 myResolver // main.js import { myResolver } from './module.js'; // 使用 myResolver myResolver(); ``` #### 3. 检查作用域 要确保 `myResolver` 在使用时处于有效的作用域内。例如,若 `myResolver` 是在某个函数内部定义的,那么它只能在该函数内部使用。 ### 关联 `SyntaxError: The requested module 'enhanced-resolve' does not provide an export named 'CachedInputFileSystem'` 错误 这两个错误可能存在关联,若 `myResolver` 的定义或者使用依赖于 `enhanced-resolve` 模块,那么 `enhanced-resolve` 模块的导入错误可能会影响 `myResolver` 的正常使用。可以按照以下步骤解决 `enhanced-resolve` 模块的错误: #### 1. 更新 `enhanced-resolve` 包 ```bash npm update enhanced-resolve ``` 或者直接指定安装最新版本: ```bash npm install enhanced-resolve@latest ``` #### 2. 检查 Node.js 版本 确保使用的是兼容的 Node.js 版本,某些 `enhanced-resolve` 版本可能依赖特定的 Node.js 版本。 #### 3. 检查导入语句 确保导入语句正确: ```javascript import { CachedInputFileSystem } from 'enhanced-resolve'; ``` #### 4. 清除缓存并重新安装依赖 ```bash npm cache clean --force rm -rf node_modules npm install ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值