1. 设置安装路径
(1)R安装路径
R_dir=/opt/R
(2)依赖包安装路径
PKGS=/opt/pkg
(3)源码包所在路径
SOURCE=/root/pkg
2. 安装依赖软件
(1)mount /dev/cdrom /mnt
(2)rm -rf /etc/yum.repos.d/*
(3)echo -e "[OS]\nname=OS\nbaseurl=file:///mnt\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/my.repo
(4)yum clean all && yum makecache
(5)yum install -y gcc gcc-gfortran gcc-c++ readline-devel libXt-devel zlib-devel bzip2-devel xz-devel.x86_64 texlive-latex
3. 安装依赖源码包
(1)cd $SCOURE/zlib-1.2.11
./configure --prefix=$PKGS/zlib && make -j4 && make install
(2)cd $SCOURE/bzip2-1.0.6
make CC='gcc -fPIC' && make install PREFIX=$PKGS/bzip && make -f Makefile-libbz2_so
(3)cd $SCOURE/xz-5.2.2
./configure --prefix=$PKGS/xz && make -j4 && make install
(4)cd $SCOURE/pcre-8.36
./configure --enable-utf8 --prefix=$PKGS/pcre && make -j4 && make install
(5)cd $SCOURE/openssl-1.0.1u
./config -fPIC --prefix=$PKGS/openssl enable-shared && ./config -t && make -j4 && make install
(6)cd $SCOURE/curl-7.57.0
env PKG_CONFIG_PATH=$PKGS/openssl/lib/pkgconfig ./configure --with-ssl --enable-utf8 --prefix=$PKGS/curl && make -j4 && make install
4. 设置环境变量
(1)export LD_LIBRARY_PATH=$PKGS/zlib/lib:$PKGS/bzip/lib:$PKGS/xz/lib:$PKGS/pcre/lib/:$PKGS/curl/lib/:$PKGS/openssl/lib
(2)export PATH=$PKGS/zlib/bin:$PKGS/bzip/bin:$PKGS/xz/bin:$PKGS/pcre/bin/:$PKGS/curl/bin/:$PKGS/openssl/bin:$PATH
5. 安装R到指定目录
(1)cd $SCOURE/R-3.4.3
(2)./configure --prefix=$R_dir --enable-R-shlib CPPFLAGS="-I$PKGS/zlib/include -I$PKGS/bzip/include -I$PKGS/xz/include -I$PKGS/pcre/include/ -I$PKGS/curl/include/ -I$PKGS/openssl/include" LDFLAGS="-L$PKGS/zlib/lib -L$PKGS/bzip/lib -L$PKGS/xz/lib -L$PKGS/pcre/lib/ -L$PKGS/curl/lib/ -L$PKGS/openssl/lib/"
(3)make -j4 && make install
网友评论