1.配置本地yum源
2.安装依赖
yum -y install gcc yum install glibc-headers yum install gcc-c++ yum install gcc-gfortran yum -y install bzip2-devel yum install glibc-headers yum install readline-devel yum install libXt-devel yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
3 安装操作
包地址获取
wget https://mirror.lzu.edu.cn/CRAN/src/base/R-4/R-4.1.0.tar.gz tar -zxvf R-4.1.0.tar.gz cd R-4.1.0 ./configure --prefix=/opt/R-4.1.0 --enable-R-shlib make make install
(1)报错:configure: error: --with-readline=yes (default) and headers/libs are not available
错误描述:–with-readline=yes(默认)和头文件/库不可用
解决办法:安装头文件和库,记得连续选中Y,否则该错误无法避免
yum install readline-devel
(2)报错:configure: error: --with-x=yes (default) and X11 headers/libs are not available
解决办法:安装头文件和库,记得连续选中Y,否则该错误无法避免
yum install libXt-devel
(3)报错:configure: error: zlib library and headers are required
错误描述:需要zlib库
原因:缺少zlib或者zlib版本过低
a.查找系统是否存在zlib
find / -name zlib
b.解决办法:安装编译zlib
wget http://www.zlib.net/fossils/zlib-1.2.8.tar.gz tar xzvf zlib-1.2.8.tar.gz cd zlib-1.2.8 ./configure --prefix=/opt/packages make && make install
当前环境执行变量引入:vi /etc/profile
export PATH=/opt/packages/bin:$PATH export LD_LIBRARY_PATH=/opt/packages/lib:$LD_LIBRARY_PATH export CFLAGS="-fPIC -I/opt/packages/include" export LDFLAGS="-fPIC -L/opt/packages/lib"
(4)报错:configure: error: bzip2 library and headers are required
解决方法:安装bzip2-devel
yum -y install bzip2-devel
(5)报错:configure: error: “liblzma library and headers are required”
解决方法:安装liblzma
yum -y install xz-devel.x86_64
(6)报错:configure: error: PCRE2 library and headers are required, or use --with-pcre1 and PCRE >= 8.32 with UTF-8 support
解决方法:
a.安装PCRE
wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz cd pcre-8.43 ./configure --prefix=/opr/pcre make make install
当前环境执行变量引入:vi /etc/profile
export PATH=/opt/pcre/bin:$PATH export LD_LIBRARY_PATH=/opt/pcre/lib:$LD_LIBRARY_PATH source /etc/profile
b.UTF-8格式设置
编辑 /root/.bash_profile
添加
export LC_ALL="zh_CN.UTF-8" export LANG="zh_CN.UTF-8" source /root/.bash_profile ./configure --prefix=/opt/R-4.1.0 --enable-R-shlib --with-pcre1
(7)报错:configure: error: libcurl >= 7.28.0 library and headers are required with support for https ##需要安装curl
yum install openssl* ##需要支持ssl服务 cd /opt wget https://curl.se/download/curl-7.47.1.tar.gz tar zxvf curl-* ./configure --prefix=/opt/curl make make install
要在环境变量中加上curl的bin路径
(8) 报错:onfigure: error: libcurl >= 7.28.0 library and headers are required with support for https
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1u.tar.gz ./config --prefix=/opt/openssl make make install
添加到环境变量
Centos7.6最终执行:
./configure --prefix=/opt/R --enable-R-shlib --with-pcre1 make make install
Centos7.9最终执行:
编译时候缺失一个依赖,在安装时进行指定
./configure --prefix=/opt/R --enable-R-shlib --with-pcre1 LDFLAGS="-L/opt/zlib-1.2.8/lib" make make install