CentOS 6.8 安装 R-3.5.0

1、系统环境 :CentOS release 6.8 (Final)

2、安装包下载: wget https://cran.r-project.org/src/base/R-3/R-3.5.0.tar.gz

3、解压并安装:
tar xf R-3.5.0.tar.gz
./configure --enable-R-shlib=yes --with-tcltk --prefix=/usr/local/R
(报错):
checking if bzip2 version >= 1.0.6... no

checking whether bzip2 support suffices... configure: error: bzip2 library and headers are required

(煎熬的过程从此开始,各种依赖,各种报错,R语言是不是不想让大家好好使用,真是服了。)

4、总结安装方法:
4.1 下载依赖包:
bzip2-1.0.6 wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
xz-5.2.2 wget http://tukaani.org/xz/xz-5.2.2.tar.gz
pcre-8.38 wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
curl-7.47.1 wget --no-check-certificate https://curl.haxx.se/download/curl-7.47.1.tar.gz

4.2 解压安装包:
tar xf bzip2-1.0.6.tar.gz -C /usr/local/
tar xf xz-5.2.2.tar.gz -C /usr/local/
tar xf pcre-8.38.tar.gz -C /usr/local/
tar xf curl-7.47.1.tar.gz -C /usr/local/
tar xf R-3.5.0.tar.gz -C /usr/local/

4.3 创建依赖包安装目录(上面所有的依赖包都要安装到这个目录,这一步很重要)
mkdir /usr/local/packages

4.4 首先安装依赖包,顺序不能乱
cd bzip2-1.0.6/
vim Makefile (修改Makefile,将第24行的CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) 改为 CFLAGS=-fPIC -Wall -Winline -O2 -g $(BIGFILES),就是在-Wall 前面加上-fPIC )
make -f Makefile-libbz2_so
make clean
make
make install PREFIX=/usr/local/packages()

 cd ../xz-5.2.2/
 ./configure --prefix=/usr/local/packages
 make -j4
 make install

 cd ../pcre-8.38/
 ./configure --enable-utf8 --prefix=/usr/local/packages
 make -j4
 make install

 cd ../curl-7.47.1/
 ./configure --prefix=/usr/local/packages
 make -j4
 make install

4.5 修改环境变量(根据实际安装路径修改)
export PATH=/usr/local/packages/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LD_LIBRARY_PATH
export CFLAGS="-I/usr/local/packages/include"
export LDFLAGS="-L/usr/local/packages/lib"

4.6 安装R-3.5.0
cd ../R-3.5.0/
mkdir builddir
cd builddir/
mkdir /usr/local/packages/R-3.5.0
../configure --prefix=/usr/local/packages/R-3.5.0
make
make install
make pdf(生成packages的pdf帮助文档,若无linux无图形界面,则不需要进行此步骤)

修改环境变量 (根据实际安装路径修改)
echo 'export PATH=/usr/local/packages/R-3.5.0/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

4.7 测试

#R

R version 3.5.0 (2018-04-23) -- "Joy in Playing"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

  1. 参考文档:
    https://blog.csdn.net/huangliangbo0805/article/details/52662835
    http://blog.sina.com.cn/s/blog_6ac25ea00102whkc.html