之前的R版本太旧,不少包装不上,需要安装新版本的R:
代码语言:javascript复制R --version
R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
于是下载最新版R:
因为没有证书,需要加上最后面的参数.
代码语言:javascript复制wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-4/R-4.2.2.tar.gz --no-check-certificate
或者使用安装证书.
代码语言:javascript复制yum install -y ca-certificates
第一次configure报错:
代码语言:javascript复制./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no
...
checking for readline/history.h... no
checking for readline/readline.h... no
checking for rl_callback_read_char in -lreadline... no
checking for main in -lncurses... no
checking for main in -ltinfo... no
checking for main in -ltermcap... no
checking for main in -ltermlib... no
checking for rl_callback_read_char in -lreadline... no
configure: error: --with-readline=yes (default) and headers/libs are not available
这是因为没有装readline这个包:
代码语言:javascript复制sudo yum install readline-devel
...
Running transaction
Installing : ncurses-devel-5.9-14.20130511.el7_4.x86_64 1/2
Installing : readline-devel-6.2-11.el7.x86_64 2/2
Verifying : readline-devel-6.2-11.el7.x86_64 1/2
Verifying : ncurses-devel-5.9-14.20130511.el7_4.x86_64 2/2
Installed:
readline-devel.x86_64 0:6.2-11.el7
Dependency Installed:
ncurses-devel.x86_64 0:5.9-14.20130511.el7_4
Complete!
然后继续配置:
代码语言:javascript复制./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no --with-readline=yes --with-libpng=yes --with-blas
...
R is now configured for x86_64-pc-linux-gnu
Source directory: .
Installation directory: /opt/R/R-4.2.2
C compiler: gcc -std=gnu11 -g -O2
Fortran fixed-form compiler: gfortran -g -O2
Default C compiler: g -std=gnu 11 -g -O2
C 11 compiler: g -std=gnu 11 -g -O2
C 14 compiler:
C 17 compiler:
C 20 compiler:
Fortran free-form compiler: gfortran -g -O2
Obj-C compiler:
Interfaces supported: tcltk
External libraries: pcre2, readline, curl
Additional capabilities: PNG, JPEG, TIFF, NLS, ICU
Options enabled: shared R library, shared BLAS, R profiling
Capabilities skipped: cairo
Options not enabled: memory profiling
Recommended packages: yes
configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally
最后一段警告信息让人不爽. 这是latex的sty包没装,于是装一下:
代码语言:javascript复制wget http://mirrors.ctan.org/fonts/inconsolata.zip
unzip inconsolata.zip
Archive: inconsolata.zip
creating: inconsolata/
...
inflating: inconsolata/tex/inconsolata.sty
...
cp -R inconsolata/* /usr/share/texmf/
sudo yum install texlive
sudo texhash
texhash: Updating /usr/share/texlive/texmf/ls-R...
texhash: Updating /usr/share/texlive/texmf-config/ls-R...
texhash: Updating /usr/share/texlive/texmf-dist/ls-R...
texhash: Updating /usr/share/texlive/texmf-local///ls-R...
texhash: Updating /usr/share/texlive/texmf-var/ls-R...
texhash: Done.
然后再配置就不会有警告信息了:
代码语言:javascript复制./configure --enable-R-shlib --prefix=/opt/R/R-4.2.2 --with-x=no --with-readline=yes --with-libpng=yes --with-blas
...
R is now configured for x86_64-pc-linux-gnu
Source directory: .
Installation directory: /opt/R/R-4.2.2
C compiler: gcc -std=gnu11 -g -O2
Fortran fixed-form compiler: gfortran -g -O2
Default C compiler: g -std=gnu 11 -g -O2
C 11 compiler: g -std=gnu 11 -g -O2
C 14 compiler:
C 17 compiler:
C 20 compiler:
Fortran free-form compiler: gfortran -g -O2
Obj-C compiler:
Interfaces supported: tcltk
External libraries: pcre2, readline, curl
Additional capabilities: PNG, JPEG, TIFF, NLS, ICU
Options enabled: shared R library, shared BLAS, R profiling
Capabilities skipped: cairo
Options not enabled: memory profiling
Recommended packages: yes
configuare 参数说明:
–enable-R-shlib 表示生成libR.so库,当需要进行gcc等编译的时候很重要,确保之后安装R-studio-server时会出现 找不到"lib.so"文件的错误。
–with-readline=yes表示用于R shell条件下的调试优化
–with-libpng=yes表示可导出png图片
–with-blas表示优化R运算并生成libRblas.so库
–prefix 设定安装路径,否则make install会去安装到/usr/lib文件夹下,非root用户没有权限.
然后再
代码语言:javascript复制make
make install
ref:
Ubntu 14.04 LTS 下编译安装R Source Code_Linux教程_Linux公社-Linux系统门户网站
全网最全:新处理器安装R所出现的报错问题 - 简书
linux服务器上装r,linux服务器安装R语言及Rstudio server_weixin_39595085的博客-CSDN博客