安装rstan时出现以下错误:
Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined从研究中了解到C++14编译器应该是可用的。如何在配置R的同时安装R.使用下面的命令配置R
./configure --with-readline=no --with-x=no安装
yum install -y devtoolset-6但是仍然不能更新C++14,rstan给出了错误。
Default C++ compiler: g++ -g -O2
C++98 compiler: g++ -g -O2
C++11 compiler: g++ -std=gnu++11 -g -O2
C++14 compiler: g++ -g -O2
C++17 compiler:
Fortran 90/95 compiler: gfortran -g -O2
Obj-C compiler: setup.sh
yum -y update
yum install -y centos-release-scl
yum install -y devtoolset-6
yum install -y devtoolset-6-gcc-gfortran
scl enable devtoolset-6 bash
scl enable devtoolset-6-gcc-gfortran bash
mkdir packages
cd packages
wget -qO-
https://downloads.sourceforge.net/project/libpng/zlib/1.2.8/zlib-
1.2.8.tar.gz | tar zvx
cd zlib-1.2.8
./configure
make
make install
cd ..
wget -qO- http://downloads.sourceforge.net/pcre/pcre-8.35.tar.gz |
tar xzv
cd pcre-8.35
./configure
make
make install
cd ..
wget -qO- http://tukaani.org/xz/xz-5.2.2.tar.gz | tar xzv
cd xz-5.2.2
./configure
make
make install
cd ..
wget -qO- https://curl.haxx.se/download/curl-7.47.1.tar.gz | tar xzv
cd curl-7.47.1
./configure
make
make install
cd ..
wget -qO- https://cran.r-project.org/src/base/R-3/R-3.4.4.tar.gz |
tar xzv
cd R-3.4.4
./configure --with-readline=no --with-x=no --prefix=/packages/R-3.4.4
F77=gfortran
make
make install发布于 2019-09-20 08:00:01
我也有这个问题,在这里我记录了如何解决它。
关键是安装适当的g++并对其进行配置。
首先,安装g++版本的>= 5,如https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Linux所述:
使用RStan需要g++版本4.9和更高版本
这里我正在安装g++8 (您可以根据自己的意愿更改版本):
跑
$ sudo yum install centos-release-scl
$ sudo yum install devtoolset-8-gcc*现在,您可以在操作系统中使用替代的g++和默认的g++。
您可以启用它并检查版本:
$ scl enable devtoolset-8 bash
$ gcc --version
$ g++ --version找到它的位置:
$ which g++
/opt/rh/devtoolset-8/root/usr/bin/g++接下来,您需要配置~/.R/Makevars,使用vim (或其他编辑器)将以下内容放入其中:
CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=/opt/rh/devtoolset-8/root/usr/bin/g++或者使用R命令:
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native -fPIC",
"CXX14=/opt/rh/devtoolset-8/root/usr/bin/g++", # or clang++ but you may need a version postfix
file = M, sep = "\n", append = TRUE)注意:这些R命令是从https://github.com/stan-dev/rstan/wiki/Configuring-C-Toolchain-for-Linux复制的,但是根据上面的位置修改了CXX14标志。
现在,您可以安装rstan包了:
install.packages("rstan")希望这能有所帮助。
PS: r用户可以使用这种方法以类似的方式修改编译器标志。
发布于 2019-03-13 16:08:31
这就是对我有用的东西:
CXX_STD = CXX14
CXX14 = g++ -std=c++11
CXX14FLAGS = -O3 -fPIC -Wno未使用-变量-Wno未使用-函数-DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION
发布于 2018-11-30 15:34:23
您不需要重新编译R,但至少需要g++-4.9 (或clang++-3.4)并在~/.R/Makevars配置文件中定义CXX14 = g++。此外,您通常需要CXX14FLAGS = -fPIC,最好使用CXX14FLAGS = -O3 -mtune = native -march = native -fPIC。所有这些都有一个wiki 页面。
https://stackoverflow.com/questions/53552166
复制相似问题