centos7 安裝rstan (R)

install.packages("rstan") 安裝失敗

試開URL’https://mirrors.e-ducation.cn/CRAN/src/contrib/rstan_2.21.2.tar.gz'
Content type 'application/x-gzip' length 1152008 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

* installing *source* package ‘rstan’ ...
** 成功將‘rstan’程序包解包並MD5和檢查
** using staged installation
** libs
Error in .shlib_internal(args) :
  C++14 standard requested but CXX14 is not defined
* removing ‘/usr/lib64/R/library/rstan’

下載的程序包在
    ‘/tmp/RtmpHaZKZK/downloaded_packages’裏
更新'.Library'裏的HTML程序包列表
Making 'packages.html' ... 做完了。
Warning message:
In install.packages("rstan") : 安裝程序包‘rstan’時退出狀態的值不是0

=====================================

安裝 步驟如下:

 

安裝新版本gcc (Install gcc gcc-9.1.0)

centos7的預裝gcc版本爲4.8.5,剛好不滿足rstan的最低要求😓。以下爲gcc-9.1.0安裝流程(一下流程會覆蓋gcc,謹慎操作):

### Install gcc gcc-9.1.0
wget
http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-9.1.0/gcc-9.1.0.tar.gz tar -xzvf gcc-9.1.0.tar.gz cd gcc-9.1.0 ./contrib/download_prerequisites mkdir build cd build ../configure --prefix=/usr -enable-checking=release --enable--long-long--with-system-zlib -enable-languages=c,c++,fortran -disable-multilib # 這樣安裝會覆蓋原有gcc make -j8 ## error make install ## error ldconfig -v

make[6]: *** [ios_locale.lo] 錯誤 1
make[6]: 離開目錄“/home/software/gcc-9.1.0/build/x86_64-pc-linux-gnu/libstdc++-v3/src/c++98”
make[5]: *** [all-recursive] 錯誤 1
make[5]: 離開目錄“/home/software/gcc-9.1.0/build/x86_64-pc-linux-gnu/libstdc++-v3/src”
make[4]: *** [all-recursive] 錯誤 1
make[4]: 離開目錄“/home/software/gcc-9.1.0/build/x86_64-pc-linux-gnu/libstdc++-v3”
make[3]: *** [all] 錯誤 2
make[3]: 離開目錄“/home/software/gcc-9.1.0/build/x86_64-pc-linux-gnu/libstdc++-v3”
make[2]: *** [all-stage1-target-libstdc++-v3] 錯誤 2
make[2]: 離開目錄“/home/software/gcc-9.1.0/build”
make[1]: *** [stage1-bubble] 錯誤 2
make[1]: 離開目錄“/home/software/gcc-9.1.0/build”
make: *** [all] 錯誤 2
您在 /var/spool/mail/root 中有郵件
(base) [root@ibiomed build]# make install
make[1]: 進入目錄“/home/software/gcc-9.1.0/build”
/bin/sh ../mkinstalldirs /usr /usr
make[2]: 進入目錄“/home/software/gcc-9.1.0/build/fixincludes”
make[2]: *** 沒有規則可以創建目標“install”。 停止。
make[2]: 離開目錄“/home/software/gcc-9.1.0/build/fixincludes”
make[1]: *** [install-fixincludes] 錯誤 2
make[1]: 離開目錄“/home/software/gcc-9.1.0/build”
make: *** [install] 錯誤 2
您在 /var/spool/mail/root 中有郵件

 

 

安裝Rcpp和rstan (install Rcpp和rstan )

進入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=g++", file = M, sep = "\n", append = TRUE)
install.packages("Rcpp") # 很重要,必須保持一致性編譯
Sys.setenv(MAKEFLAGS = "-j8")
install.packages("rstan", type = "source")
install.packages("ggstatsplot")

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章