安装时 rstan C++14 错误 (centos)
rstan C++14 error while installing (centos)
安装 rstan 时出现以下错误:
Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined
通过研究得知 C++14 编译器应该可用。
如何在配置 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
您不需要重新编译 R,但至少需要 g++-4.9(或 clang++-3.4)并在 ~/.R/Makevars 配置文件中定义 CXX14 = g++
。此外,您通常需要 CXX14FLAGS = -fPIC
,并且最好有 CXX14FLAGS = -O3 -mtune = native -march = native -fPIC
。所有这些都有一个 wiki page。
进行了以下更改,现在工作正常。需要为 R-3.4.4 定义 gcc 路径并使用 yum install -y devtoolset-6。谢谢你的帮助
yum install -y centos-release-scl
yum install -y devtoolset-6
yum install -y bzip2-devel
source scl_source enable devtoolset-6
also added the Path to gcc in build.sh
export PATH=/opt/rh/devtoolset-6/root/bin:$PATH
这对我有用:
CXX_STD = CXX14
CXX14 = g++ -std=c++11
CXX14FLAGS = -O3 -fPIC -Wno-unused-variable -Wno-unused-function -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION
我也遇到了这个问题,记录一下怎么解决的
关键是安装正确的 g++ 并配置它。
首先,安装 g++ Version >= 5 as https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Linux said:
Using RStan requires either g++ version 4.9 and up
这里我安装的是g++8(版本可以随意更改):
运行
$ sudo yum install centos-release-scl
$ sudo yum install devtoolset-8-gcc*
现在您的 OS.
中有一个替代 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)
NOTE: these R commands are copied from https://github.com/stan-dev/rstan/wiki/Configuring-C-Toolchain-for-Linux but CXX14 flag is modified according to the location above.
现在,您可以安装 rstan
软件包:
install.packages("rstan")
希望对您有所帮助。
PS:R 用户可以使用这种方法以类似的方式修改编译器标志。
我遇到了同样的问题。
这是我的解决方案,以防对其他人有帮助。
在 CentOS 7 上,我:
从这里安装了 V8 头文件和共享库:https://pkgs.org/download/v8-devel 41 (EPEL_x86_64)
将 gcc 从版本 4 升级到 9.3.1
在 R 中,我:
删除了 rstan 和 StanHeaders
在新的 R 会话中安装了 rstan 和 StanHeaders
在此处发布了关于 Stan 论坛的讨论:https://discourse.mc-stan.org/t/problem-installing-rstan-2-21-using-r-4-0-1-on-centos-7/17784/9
安装 rstan 时出现以下错误:
Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined
通过研究得知 C++14 编译器应该可用。 如何在配置 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
您不需要重新编译 R,但至少需要 g++-4.9(或 clang++-3.4)并在 ~/.R/Makevars 配置文件中定义 CXX14 = g++
。此外,您通常需要 CXX14FLAGS = -fPIC
,并且最好有 CXX14FLAGS = -O3 -mtune = native -march = native -fPIC
。所有这些都有一个 wiki page。
进行了以下更改,现在工作正常。需要为 R-3.4.4 定义 gcc 路径并使用 yum install -y devtoolset-6。谢谢你的帮助
yum install -y centos-release-scl
yum install -y devtoolset-6
yum install -y bzip2-devel
source scl_source enable devtoolset-6
also added the Path to gcc in build.sh
export PATH=/opt/rh/devtoolset-6/root/bin:$PATH
这对我有用:
CXX_STD = CXX14
CXX14 = g++ -std=c++11
CXX14FLAGS = -O3 -fPIC -Wno-unused-variable -Wno-unused-function -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION
我也遇到了这个问题,记录一下怎么解决的
关键是安装正确的 g++ 并配置它。
首先,安装 g++ Version >= 5 as https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Linux said:
Using RStan requires either g++ version 4.9 and up
这里我安装的是g++8(版本可以随意更改):
运行
$ sudo yum install centos-release-scl
$ sudo yum install devtoolset-8-gcc*
现在您的 OS.
中有一个替代 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)
NOTE: these R commands are copied from https://github.com/stan-dev/rstan/wiki/Configuring-C-Toolchain-for-Linux but CXX14 flag is modified according to the location above.
现在,您可以安装 rstan
软件包:
install.packages("rstan")
希望对您有所帮助。
PS:R 用户可以使用这种方法以类似的方式修改编译器标志。
我遇到了同样的问题。 这是我的解决方案,以防对其他人有帮助。
在 CentOS 7 上,我:
从这里安装了 V8 头文件和共享库:https://pkgs.org/download/v8-devel 41 (EPEL_x86_64)
将 gcc 从版本 4 升级到 9.3.1
在 R 中,我:
删除了 rstan 和 StanHeaders
在新的 R 会话中安装了 rstan 和 StanHeaders
在此处发布了关于 Stan 论坛的讨论:https://discourse.mc-stan.org/t/problem-installing-rstan-2-21-using-r-4-0-1-on-centos-7/17784/9