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 ##让环境变量立马生效