R-3.3.1源碼安裝

1、yum install readline-devel gcc*

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

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

    yum install openssl*                                  ##需要支持ssl服務

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

報錯:

/usr/bin/ld: warning: libpcre.so.1, needed by ../../lib/libR.so, not found (try using -rpath or -rpath-link)

/usr/bin/ld: warning: liblzma.so.5, needed by ../../lib/libR.so, not found (try using -rpath or -rpath-link)

../../lib/libR.so: undefined reference to `lzma_code@XZ_5.0'

../../lib/libR.so: undefined reference to `lzma_raw_encoder@XZ_5.0'

../../lib/libR.so: undefined reference to `lzma_stream_decoder@XZ_5.0'

../../lib/libR.so: undefined reference to `pcre_free'

../../lib/libR.so: undefined reference to `lzma_lzma_preset@XZ_5.0'

../../lib/libR.so: undefined reference to `lzma_raw_decoder@XZ_5.0'

../../lib/libR.so: undefined reference to `pcre_version'

../../lib/libR.so: undefined reference to `pcre_exec'

../../lib/libR.so: undefined reference to `pcre_config'

../../lib/libR.so: undefined reference to `pcre_fullinfo'

../../lib/libR.so: undefined reference to `pcre_maketables'

../../lib/libR.so: undefined reference to `pcre_compile'

../../lib/libR.so: undefined reference to `lzma_end@XZ_5.0'

../../lib/libR.so: undefined reference to `lzma_alone_decoder@XZ_5.0'

../../lib/libR.so: undefined reference to `lzma_version_string@XZ_5.0'

../../lib/libR.so: undefined reference to `lzma_crc64@XZ_5.0'

../../lib/libR.so: undefined reference to `pcre_study'

../../lib/libR.so: undefined reference to `lzma_stream_encoder@XZ_5.0'

collect2: ld returned 1 exit status

make[3]: *** [R.bin] Error 1

make[3]: Leaving directory `/root/R-3.3.1/src/main'

make[2]: *** [R] Error 2

make[2]: Leaving directory `/root/R-3.3.1/src/main'

make[1]: *** [R] Error 1

make[1]: Leaving directory `/root/R-3.3.1/src'

make: *** [R] Error 1

此處報錯是由於沒有找到動態庫,看第一二行

解決方法:添加動態庫

#cat /etc/ld.so.conf

include ld.so.conf.d/*.conf

/opt/pcre-8.39/lib

/opt/xz-5.2.2/lib

然後執行

#ldconfig

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   ##讓環境變量立馬生效


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章