linux系统redhat8.3安装R-4.0.3(编译安装)
1、查看当前系统
[root@rhel8 home]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.3 (Ootpa)
[root@rhel8 home]# hostnamectl
Static hostname: rhel8
Icon name: computer-vm
Chassis: vm
Machine ID: bd17d96c46664b648189528dede70fa5
Boot ID: 9ea60af5584142d685d2b13bd5ad2929
Virtualization: vmware
Operating System: Red Hat Enterprise Linux 8.3 (Ootpa)
CPE OS Name: cpe:/o:redhat:enterprise_linux:8.3:GA
Kernel: Linux 4.18.0-240.el8.x86_64
Architecture: x86-64
2、测试R
[root@rhel8 home]# R
bash: R: command not found...
3、下载R安装包
[root@rhel8 home]# wget https://mirror.bjtu.edu.cn/cran/src/base/R-4/R-4.0.3.tar.gz
--2021-02-01 16:53:46-- https://mirror.bjtu.edu.cn/cran/src/base/R-4/R-4.0.3.tar.gz
Resolving mirror.bjtu.edu.cn (mirror.bjtu.edu.cn)... 202.112.154.58, 2001:da8:205::58
Connecting to mirror.bjtu.edu.cn (mirror.bjtu.edu.cn)|202.112.154.58|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 33497010 (32M) [application/octet-stream]
Saving to: ‘R-4.0.3.tar.gz’
R-4.0.3.tar.gz 100%[==========================================================>] 31.94M 66.9MB/s in 0.5s
2021-02-01 16:53:47 (66.9 MB/s) - ‘R-4.0.3.tar.gz’ saved [33497010/33497010]
[root@rhel8 home]# ls
liujiaxin01 R-4.0.3.tar.gz
[root@rhel8 home]# tar -xzvf R-4.0.3.tar.gz
liujiaxin01 R-4.0.3 R-4.0.3.tar.gz
[root@rhel8 home]# cd R-4.0.3/
[root@rhel8 R-4.0.3]# ls
ChangeLog configure COPYING etc m4 Makefile.fw po share SVN-REVISION tools VERSION-NICK
config.site configure.ac doc INSTALL Makeconf.in Makefile.in README src tests VERSION
4、创建R安装目录
[root@rhel8 R-4.0.3]# mkdir -p /home/software/R
5、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
checking for cl.exe... no
configure: error: in `/home/R-4.0.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
6、
[root@rhel8 R-4.0.3]# yum install gcc-c++ -y
…………
…………
Installed:
cpp-8.3.1-5.1.el8.x86_64 gcc-8.3.1-5.1.el8.x86_64 gcc-c++-8.3.1-5.1.el8.x86_64
glibc-devel-2.28-127.el8.x86_64 glibc-headers-2.28-127.el8.x86_64 isl-0.16.1-6.el8.x86_64
kernel-headers-4.18.0-240.el8.x86_64 libstdc++-devel-8.3.1-5.1.el8.x86_64 libxcrypt-devel-4.1.1-4.el8.x86_64
Complete!
7、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
checking whether we are using the GNU Fortran compiler... no
checking whether accepts -g... no
configure: error: No Fortran compiler found
8、
[root@rhel8 R-4.0.3]# yum install gcc-gfortran -y
…………
…………
Installed:
gcc-gfortran-8.3.1-5.1.el8.x86_64 libgfortran-8.3.1-5.1.el8.x86_64 libquadmath-8.3.1-5.1.el8.x86_64
libquadmath-devel-8.3.1-5.1.el8.x86_64
Complete!
9、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
checking for main in -ltermlib... no
checking for rl_callback_read_char in -lreadline... no
configure: error: --with-readline=yes (default) and headers/libs are not available
10、
[root@rhel8 R-4.0.3]# yum install readline-devel -y
…………
…………
Installed:
ncurses-c++-libs-6.1-7.20180224.el8.x86_64 ncurses-devel-6.1-7.20180224.el8.x86_64 readline-devel-7.0-10.el8.x86_64
Complete!
11、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
checking for mbstate_t... yes
checking for ICU... no
checking for X... no
configure: error: --with-x=yes (default) and X11 headers/libs are not available
12、
[root@rhel8 R-4.0.3]# yum install libXt-devel -y
…………
…………
Installed:
libICE-devel-1.0.9-15.el8.x86_64 libSM-devel-1.2.3-1.el8.x86_64 libX11-devel-1.6.8-3.el8.x86_64
libXau-devel-1.0.9-3.el8.x86_64 libXt-devel-1.1.5-12.el8.x86_64 libxcb-devel-1.13.1-1.el8.x86_64
xorg-x11-proto-devel-2020.1-3.el8.noarch
Complete!
13、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
checking for XDR support... no
checking for inflateInit2_ in -lz... no
checking whether zlib support suffices... configure: error: zlib library and headers are required
14、
[root@rhel8 R-4.0.3]# yum install zlib-devel -y
…………
…………
Installed:
zlib-devel-1.2.11-16.el8_2.x86_64
Complete!
15、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
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
16、
[root@rhel8 R-4.0.3]# yum -y install bzip2-devel
…………
…………
Installed:
bzip2-devel-1.0.6-26.el8.x86_64
Complete!
17、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
checking whether bzip2 support suffices... yes
checking for lzma_version_number in -llzma... no
configure: error: "liblzma library and headers are required"
18、
[root@rhel8 R-4.0.3]# yum -y install xz-devel.x86_64
…………
…………
Installed:
xz-devel-5.2.4-3.el8.x86_64
Complete!
19、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
checking for pcre2-config... no
checking whether PCRE support suffices... no
configure: error: PCRE2 library and headers are required, or use --with-pcre1 and PCRE >= 8.32 with UTF-8 support
20、下载安装PCRE2
[root@rhel8 R-4.0.3]# wget -P /home/ ftp://ftp.pcre.org/pub/pcre/pcre2-10.36.zip
--2021-02-01 17:19:44-- ftp://ftp.pcre.org/pub/pcre/pcre2-10.36.zip
=> ‘/home/pcre2-10.36.zip’
Resolving ftp.pcre.org (ftp.pcre.org)... 131.111.8.88
Connecting to ftp.pcre.org (ftp.pcre.org)|131.111.8.88|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /pub/pcre ... done.
==> SIZE pcre2-10.36.zip ... 2550081
==> PASV ... done. ==> RETR pcre2-10.36.zip ... done.
Length: 2550081 (2.4M) (unauthoritative)
pcre2-10.36.zip 100%[==========================================================>] 2.43M 74.3KB/s in 80s
2021-02-01 17:21:12 (31.2 KB/s) - ‘/home/pcre2-10.36.zip’ saved [2550081]
[root@rhel8 R-4.0.3]# cd /home/
[root@rhel8 home]# ls
liujiaxin01 pcre2-10.36.zip R-4.0.3 R-4.0.3.tar.gz software
[root@rhel8 home]# unzip pcre2-10.36.zip
[root@rhel8 home]# ls
liujiaxin01 pcre2-10.36 pcre2-10.36.zip R-4.0.3 R-4.0.3.tar.gz software
[root@rhel8 home]# cd pcre2-10.36/
[root@rhel8 pcre2-10.36]# ls
132html cmake configure.ac install-sh m4 perltest.sh src
aclocal.m4 CMakeLists.txt COPYING libpcre2-16.pc.in Makefile.am PrepareRelease testdata
ar-lib compile depcomp libpcre2-32.pc.in Makefile.in README test-driver
AUTHORS config-cmake.h.in Detrail libpcre2-8.pc.in missing RunGrepTest
ChangeLog config.guess doc libpcre2-posix.pc.in NEWS RunGrepTest.bat
CheckMan config.sub HACKING LICENCE NON-AUTOTOOLS-BUILD RunTest
CleanTxt configure INSTALL ltmain.sh pcre2-config.in RunTest.bat
21、
[root@rhel8 pcre2-10.36]# ./configure
…………
…………
config.status: error: in `/home/pcre2-10.36':
config.status: error: Something went wrong bootstrapping makefile fragments
for automatic dependency tracking. If GNU make was not used, consider
re-running the configure script with MAKE="gmake" (or whatever is
necessary). You can also try re-running configure with the
'--disable-dependency-tracking' option to at least be able to build
the package (albeit without support for automatic dependency tracking).
See `config.log' for more details
22、
[root@rhel8 pcre2-10.36]# yum install make -y
…………
…………
Installed:
make-1:4.2.1-10.el8.x86_64
Complete!
23、
[root@rhel8 pcre2-10.36]# ./configure
…………
…………
Link pcre2test with libedit ........ : no
Link pcre2test with libreadline .... : no
Valgrind support ................... : no
Code coverage ...................... : no
Fuzzer support ..................... : no
Use %zu and %td .................... : auto
24、
[root@rhel8 pcre2-10.36]# make
…………
…………
CCLD libpcre2-8.la
CCLD pcre2grep
CC src/pcre2test-pcre2test.o
CC src/libpcre2_posix_la-pcre2posix.lo
CCLD libpcre2-posix.la
CCLD pcre2test
make[1]: Leaving directory '/home/pcre2-10.36'
25、
[root@rhel8 pcre2-10.36]# make install
…………
…………
/usr/bin/mkdir -p '/usr/local/lib/pkgconfig'
/usr/bin/install -c -m 644 libpcre2-8.pc libpcre2-posix.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory '/home/pcre2-10.36'
make[1]: Leaving directory '/home/pcre2-10.36'
26、
[root@rhel8 pcre2-10.36]# cd /home/R-4.0.3/
[root@rhel8 R-4.0.3]# ls
ChangeLog configure doc m4 Makefile.in Makefrag.cxx README SVN-REVISION VERSION
config.log configure.ac etc Makeconf.in Makefrag.cc Makefrag.m share tests VERSION-NICK
config.site COPYING INSTALL Makefile.fw Makefrag.cc_lo po src tools
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
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
27、
[root@rhel8 R-4.0.3]# yum install curl curl-devel -y
…………
…………
Installed:
libcurl-devel-7.61.1-14.el8.x86_64
Complete!
28、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
Recommended packages: yes
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: you cannot build PDF versions of the R manuals
configure: WARNING: you cannot build PDF versions of vignettes and help pages
29、
[root@rhel8 R-4.0.3]# yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
…………
…………
Installed:
copy-jdk-configs-3.7-4.el8.noarch java-1.8.0-openjdk-1:1.8.0.265.b01-4.el8.x86_64
java-1.8.0-openjdk-devel-1:1.8.0.265.b01-4.el8.x86_64 java-1.8.0-openjdk-headless-1:1.8.0.265.b01-4.el8.x86_64
javapackages-filesystem-5.3.0-1.module+el8+2447+6f56d9a6.noarch lksctp-tools-1.0.18-3.el8.x86_64
ttmkfdir-3.0.9-54.el8.x86_64 tzdata-java-2020a-1.el8.noarch
xorg-x11-fonts-Type1-7.5-19.el8.noarch
Complete!
30、
[root@rhel8 R-4.0.3]# ./configure --prefix=/home/software/R/ --enable-R-shlib
…………
…………
Recommended packages: yes
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: you cannot build PDF versions of the R manuals
configure: WARNING: you cannot build PDF versions of vignettes and help pages
31、
[root@rhel8 R-4.0.3]# make
…………
…………
JAVA_HOME : /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-4.el8.x86_64/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /home/R-4.0.3
Done.
make[1]: Leaving directory '/home/R-4.0.3'
32、
[root@rhel8 R-4.0.3]# make install
…………
…………
building HTML index ...
make[2]: Leaving directory '/home/R-4.0.3/src/library'
make[1]: Leaving directory '/home/R-4.0.3/src'
make[1]: Entering directory '/home/R-4.0.3/tests'
make[1]: Nothing to be done for 'install'.
make[1]: Leaving directory '/home/R-4.0.3/tests'
33、添加环境变量
[root@rhel8 R-4.0.3]# vim /etc/profile
R_HOME=/home/software/R
PATH=$PATH:$R_HOME/bin ## 添加后保存退出
[root@rhel8 R-4.0.3]# source /etc/profile ## 生效
34、测试R
[root@rhel8 R-4.0.3]# R
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> 5 + 8
[1] 13
> quit()
Save workspace image? [y/n/c]: n
安装完成。
35、参考
https://blog.csdn.net/stone1116/article/details/112986790
https://blog.csdn.net/wumiqing1/article/details/54232345
https://blog.csdn.net/john_f_lau/article/details/17652523
http://blog.sina.com.cn/s/blog_6caea8bf0100zfbu.html
https://blog.csdn.net/weixin_43404791/article/details/108980273
https://blog.csdn.net/weixin_43833642/article/details/105048704