编译安装R(20201003更新)
Tofloor
poster avatar
探索
deepin
2019-03-18 19:26
Author
本帖最后由 china140106 于 2020-10-19 21:56 编辑

趁国庆节休息,下载deepin20(1002)版,全新安装了一下,就此机会下了个最新版的R(4.0.2)进行编译安装,过程摘要如下。

从CRAN下载最新版的源码包,安装步骤如下:

1、环境检查
./configure --prefix=/home/(me)/R --enable-R-shlib --with-cairo=yes
以下问题的解决方案

configure: error: –with-readline=yes (default) and headers/libs are not available,需要安装libreadline6-dev:
    sudo apt-get install libreadline6-dev

configure: error: bzip2 library and headers are required
    sudo apt-get install libbz2-dev

configure: error: "liblzma library and headers are required"
    sudo apt-get install liblzma-dev

configure: error: libcurl >= 7.22.0 library and headers are required with support for https
    sudo apt-get install libcurl4-openssl-dev

checking whether the C compiler works... no
configure: error: in `/home/explore/R/R-4.0.2':
configure: error: C compiler cannot create executables
        sudo apt-get install build-essential

checking whether we are using the GNU Fortran compiler... no
checking whether  accepts -g... no
configure: error: No Fortran compiler found
        sudo apt-get install gfortran

configure: error: --with-x=yes (default) and X11 headers/libs are not available
        sudo apt-get install libxt-dev

configure: error: zlib library and headers are required
        sudo apt-get install zlib1g-dev

configure: error: PCRE2 library and headers are required, or use --with-pcre1 and PCRE >= 8.32 with UTF-8 support
        sudo apt-get install libpcre2-dev


2、编译安装
make    #约十分钟
make install

3、移动快捷方式
将安装目录下bin文件夹中文件R生成一个快捷方式,复制到/usr/bin
可使用如下命令:

mv /链接所在目录/R /usr/bin

4、若RStudio中不能录入中文
可复制
/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts
中的
libfcitxplatforminputcontextplugin.so

/opt/apps/com.rstudio.rstudio/files/plugins/platforminputcontexts
Reply Favorite View the author
All Replies
avatar
探索
deepin
2019-03-26 04:45
#1
今天作图时发现报错:
Error in RStudioGD() :
  Shadow graphics device error: r error 4 (R code execution error)
此外: Warning message:
In grDevices:::png("/tmp/Rtmpha4cxR/1d011b60001b4061a5d5263361db3361.png",  :
  本R版本不支持png

解决过程如下
1、检查兼容性
> capabilities()
       jpeg         png        tiff       tcltk         X11        aqua
      FALSE       FALSE       FALSE       FALSE        TRUE       FALSE
   http/ftp     sockets      libxml        fifo      cledit       iconv
       TRUE        TRUE        TRUE        TRUE        TRUE        TRUE
        NLS     profmem       cairo         ICU long.double     libcurl
       TRUE       FALSE       FALSE        TRUE        TRUE        TRUE

2、安装缺失软件
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
sudo apt-get install libtiff-dev

3、重新编译安装
Reply View the author
avatar
bobo
deepin
2019-03-26 05:11
#2
硬核,收藏一个。
Reply View the author
avatar
探索
deepin
2019-04-14 04:02
#3
前几天又发现一个问题,画图时无法显示汉字,总提示x11没有相应字体。
检索相关资料后发现可能是cairo没有安装,检查兼容性如前一条所示。

先尝试安装缺失软件,如下:
sudo apt-get install libcairo-dev
安装后问题依旧

再检索资料后发现可能需要在编译安装时加上cairo选项,如下:
./configure --prefix=/home/(me)/R --enable-R-shlib --with-cairo=yes
重新编译安装后问题解决。

############################################################
在这个过程中,为解决这个问题还安装了一个R包Cairo。该包也可解决这个问题,但和RStudio结合的不够好,因此又重新编译安装了一遍。
Reply View the author
avatar
johnmy
deepin
2019-12-17 06:53
#4
本帖最后由 johnmy 于 2019-12-17 10:24 编辑

还运行了:
  1. sudo apt-get install texlive
  2. sudo apt-get install texlive-fonts-extra
  3. wget http://mirrors.ctan.org/fonts/inconsolata.zip

  4. unzip inconsolata.zip

  5. cp -Rfp inconsolata/* /usr/share/texmf/
  6. sudo apt-get install texinfo
  7. mktexlsr
Copy the Code

Reply View the author