1源码安装,6离线源码安装R3

R-3.3.1源码安装,r-3.3.1源码

标签:r3.3.1 源码 解决依赖关系

1、yum install readline-devel

2、yum install libXt-devel

3、tar zxvf R-3.3.1.tar.gz

cd R-3.3.1

    ./configure –prefix=/opt/R-3.3.1   –enable-R-shlib

    报错:

    checking for zlib.h… yes

    checking if zlib version >= 1.2.5… no

    checking whether zlib support suffices… configure: error: zlib
library and headers are required  ##缺少zlib或者zlib版本过低

4、安装zlib

tar xvf zlib-1.2.8.tar.gz

tar xvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure –prefix=/opt/zlib-1.2.8

make && make install

5、cd /root/R-3.3.1

./configure –prefix=/opt/R-3.3.1   –enable-R-shlib
LDFLAGS=”-L/opt/zlib-1.2.8/lib” CPPFLAGS=”-I/opt/zlib-1.2.8/include”

报错:

checking for zlib.h… yes

checking if zlib version >= 1.2.5… yes

checking whether zlib support suffices… yes

checking mmap support for zlib… yes

checking for BZ2_bzlibVersion in -lbz2… no

checking whether bzip2 support suffices… configure: error: bzip2
library and headers are required  ##zlib版本已经符合要求,缺少bzip2

6、安装bzip2

tar zxvf bzip2-1.0.6.tar.gz

cd bzip2-1.0.6

make -f Makefile-libbz2_so

make clean

make 

make install PREFIX=/opt/bzip2-1.0.6

7、./configure –prefix=/opt/R-3.3.1   –enable-R-shlib
LDFLAGS=”-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib”
CPPFLAGS=”-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include”

报错:

checking if bzip2 version >= 1.0.6… yes

checking whether bzip2 support suffices… no

checking for lzma_version_number in -llzma… no
 ##bzip2版本符合要求,但是lzma(xz软件包)缺少

8、安装xz

tar zxvf xz-5.2.2.tar.gz

cd /root/xz-5.2.2

./configure –prefix=/opt/xz-5.2.2

make -j3

make install

9、./configure –prefix=/opt/R-3.3.1   –enable-R-shlib
LDFLAGS=”-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib
-L/opt/xz-5.2.2/lib” CPPFLAGS=”-I/opt/zlib-1.2.8/include
-I/opt/bzip2-1.0.6/include -I/opt/xz-5.2.2/include”

报错:

checking whether bzip2 support suffices… no

checking for lzma_version_number in -llzma… yes

checking lzma.h usability… yes

checking lzma.h presence… yes

checking for lzma.h… yes

checking if lzma version >= 5.0.3… yes

checking for pcre_fullinfo in -lpcre… no     

checking whether PCRE support suffices… configure: error: pcre >=
8.10 library and headers are required
 ##xz版本符合要求,prce版本过低或者缺少

10、安装pcre

tar zxvf pcre-8.39.tar.gz

cd /root/pcre-8.39

./configure  –prefix=/opt/pcre-8.39

make -j3 && make install

11、./configure –prefix=/opt/R-3.3.1   –enable-R-shlib
LDFLAGS=”-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib
-L/opt/xz-5.2.2/lib -L/opt/pcre-8.39/lib”
CPPFLAGS=”-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include
-I/opt/xz-5.2.2/include -I/opt/pcre-8.39/include”

报错:

checking for pcre.h… yes

checking pcre/pcre.h usability… no

checking pcre/pcre.h presence… no

checking for pcre/pcre.h… no

checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support…
no

checking whether PCRE support suffices… configure: error: pcre >=
8.10 library and headers are required   ##PCRE需要安装–enable-utf8

12、重新安装pcre

rm -rf /opt/pcre-8.39

cd /root/pcre-8.39  

./configure  –prefix=/opt/pcre-8.39  –enable-utf8

make -j3 && make install

13、./configure –prefix=/opt/R-3.3.1   –enable-R-shlib
LDFLAGS=”-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib
-L/opt/xz-5.2.2/lib -L/opt/pcre-8.39/lib”
CPPFLAGS=”-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include
-I/opt/xz-5.2.2/include -I/opt/pcre-8.39/include/”

报错:

checking pcre/pcre.h usability… no

checking pcre/pcre.h presence… no

checking for pcre/pcre.h… no

checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support…
yes

checking if PCRE version >= 8.32… yes

checking whether PCRE support suffices… yes

checking for curl-config… no

checking curl/curl.h usability… no

checking curl/curl.h presence… no

checking for curl/curl.h… no

configure: error: libcurl >= 7.28.0 library and headers are required
with support for https    ##需要安装curl

14、安装curl

tar zxvf curl-7.50.1.tar.gz

cd /root/curl-7.50.1

./configure  –prefix=/opt/curl-7.50.1

make && make install

15、./configure –prefix=/opt/R-3.3.1 –enable-R-shlib
 LDFLAGS=”-L/opt/zlib-1.2.8/lib  -L/opt/bzip2-1.0.6/lib
-L/opt/xz-5.2.2/lib -L/opt/pcre-8.39/lib -L/opt/curl-7.50.1/lib”
CPPFLAGS=”-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include
-I/opt/xz-5.2.2/include -I/opt/pcre-8.39/include
-I/opt/curl-7.50.1/include”

报错:

checking curl/curl.h usability… yes

checking curl/curl.h presence… yes

checking for curl/curl.h… yes

checking if libcurl is version 7 and >= 7.28.0… yes

checking if libcurl supports https… no

configure: error: libcurl >= 7.28.0 library and headers are required
with support for https
 ##这是一个大坑需要在环境变量中加上curl的bin路径,如果没有报错,那肯定是之前系统默认安装的curl造成的,为了

                                                                        
                     
消除潜在风险,是否有报错,请必须执行下面的操作,系统默认安装的curl请保留,防止造成别的系统程序依赖缺失

16、最终操作

    ./configure –prefix=/opt/R-3.3.1 –enable-R-shlib
 LDFLAGS=”-L/opt/zlib-1.2.8/lib  -L/opt/bzip2-1.0.6/lib
-L/opt/xz-5.2.2/lib -L/opt/pcre-8.39/lib -L/opt/curl-7.50.1/lib”
CPPFLAGS=”-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include
-I/opt/xz-5.2.2/include -I/opt/pcre-8.39/include
-I/opt/curl-7.50.1/include”

vim /etc/profile 

export PATH=$PATH:$JAVA_HOME/bin:/opt/curl-7.50.1/bin                  
 ##在这一行加上”:/opt/curl-7.50.1/bin”

    source /etc/profile                                                
     ##让环境变量立马生效

验证;

echo $PATH

/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/java/jdk1.8.0_74/bin:/opt/curl-7.50.1/bin

    make

make install

vim /etc/profile      ##添加R源环境变量

export PATH=$PATH:$JAVA_HOME/bin:/opt/curl-7.50.1/bin:/opt/R-3.3.1/bin

    source /etc/profile   ##让环境变量立马生效

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