我在Linux Centos7上使用R。该服务器使用的是Java版本1.8,我无法更改它。
我们的系统管理员告诉我,他们无法安装R,因为它需要Java 1.7。我可以安装基本R。但是,如果没有R-devel,我将无法安装和使用软件包。
我希望有一种配置R或告诉它使用Java 1.8的方法。有吗?
这是尝试安装R-devel时的终端输出:
[myname@myip ~]$ sudo yum install R-devel
Loaded plugins: changelog, fastestmirror, priorities, versionlock
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 17 kB 00:00
* epel: mirrors.develooper.com
centos-base-prod | 1.5 kB 00:00:00
centos-cpm-prod | 1.5 kB 00:00:00
centos-epel-prod | 1.5 kB 00:00:00
centos-extras-prod | 1.5 kB 00:00:00
centos-hips-prod | 1.5 kB 00:00:00
centos-itsec-prod | 1.5 kB 00:00:00
centos-pbis-prod | 1.5 kB 00:00:00
centos-puppet3-prod | 1.5 kB 00:00:00
centos-sclo-rh | 3.0 kB 00:00:00
centos-serverspec-prod | 1.5 kB 00:00:00
centos-updates-prod | 1.5 kB 00:00:00
centos_itsec_prod | 1.5 kB 00:00:00
collectd-enterprise | 1.5 kB 00:00:00
epel | 3.2 kB 00:00:00
gd-prod-centos-v6-64bit-scl | 1.5 kB 00:00:00
gd-prod-centos-v6-64bit-tms | 1.5 kB 00:00:00
gd-prod-centos-v7-64bit-base | 1.5 kB 00:00:00
gd-prod-centos-v7-64bit-epel | 1.5 kB 00:00:00
gd-prod-centos-v7-64bit-extras | 1.5 kB 00:00:00
gd-prod-centos-v7-64bit-hips | 1.5 kB 00:00:00
gd-prod-centos-v7-64bit-pan | 1.5 kB 00:00:00
gd-prod-centos-v7-64bit-sensu | 1.5 kB 00:00:00
gd-prod-centos-v7-64bit-updates | 1.5 kB 00:00:00
gdsnow | 1.5 kB 00:00:00
gutils | 1.5 kB 00:00:00
prod_centos_7_noarch_gd-snow | 1.5 kB 00:00:00
prod_centos_7_x86_64_saltstack | 2.9 kB 00:00:00
sensu-enterprise | 1.5 kB 00:00:00
yumrepos | 1.5 kB 00:00:00
(1/7): centos-itsec-prod/x86_64/primary | 10 kB 00:00:00
(2/7): centos-hips-prod/x86_64/primary | 8.8 kB 00:00:00
(3/7): epel/x86_64/updateinfo | 948 kB 00:00:00
(4/7): centos_itsec_prod/x86_64/primary | 10 kB 00:00:00
(5/7): gd-prod-centos-v7-64bit-hips/primary | 8.8 kB 00:00:00
(6/7): epel/x86_64/primary | 3.6 MB 00:00:00
(7/7): sensu-enterprise/x86_64/primary | 495 kB 00:00:00
centos-hips-prod 72/72
centos-itsec-prod 82/82
centos_itsec_prod 82/82
epel 12723/12723
gd-prod-centos-v7-64bit-hips 72/72
sensu-enterprise 4254/4254
Resolving Dependencies
--> Running transaction check
---> Package R-devel.x86_64 0:3.5.1-1.el7 will be installed
--> Processing Dependency: R-java-devel = 3.5.1-1.el7 for package: R-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: R-core-devel = 3.5.1-1.el7 for package: R-devel-3.5.1-1.el7.x86_64
--> Running transaction check
---> Package R-core-devel.x86_64 0:3.5.1-1.el7 will be installed
--> Processing Dependency: tre-devel for package: R-core-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: tk-devel for package: R-core-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: texinfo-tex for package: R-core-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: tcl-devel for package: R-core-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: libicu-devel for package: R-core-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: libX11-devel for package: R-core-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: gcc-gfortran for package: R-core-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: gcc-c++ for package: R-core-devel-3.5.1-1.el7.x86_64
--> Processing Dependency: bzip2-devel for package: R-core-devel-3.5.1-1.el7.x86_64
---> Package R-java-devel.x86_64 0:3.5.1-1.el7 will be installed
--> Processing Dependency: java-devel for package: R-java-devel-3.5.1-1.el7.x86_64
Package 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64 is obsoleted by 2000:gd-jdk8-1.8.0_92-fcs.x86_64 which is already installed
--> Running transaction check
---> Package R-java-devel.x86_64 0:3.5.1-1.el7 will be installed
--> Processing Dependency: java-devel for package: R-java-devel-3.5.1-1.el7.x86_64
Package 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64 is obsoleted by 2000:gd-jdk8-1.8.0_92-fcs.x86_64 which is already installed
---> Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed
---> Package gcc-c++.x86_64 0:4.8.5-28.el7_5.1 will be installed
--> Processing Dependency: libstdc++-devel = 4.8.5-28.el7_5.1 for package: gcc-c++-4.8.5-28.el7_5.1.x86_64
---> Package gcc-gfortran.x86_64 0:4.8.5-28.el7_5.1 will be installed
--> Processing Dependency: libquadmath-devel = 4.8.5-28.el7_5.1 for package: gcc-gfortran-4.8.5-28.el7_5.1.x86_64
---> Package libX11-devel.x86_64 0:1.6.5-1.el7 will be installed
--> Processing Dependency: pkgconfig(xcb) >= 1.11.1 for package: libX11-devel-1.6.5-1.el7.x86_64
--> Processing Dependency: pkgconfig(xproto) for package: libX11-devel-1.6.5-1.el7.x86_64
--> Processing Dependency: pkgconfig(xcb) for package: libX11-devel-1.6.5-1.el7.x86_64
--> Processing Dependency: pkgconfig(kbproto) for package: libX11-devel-1.6.5-1.el7.x86_64
---> Package libicu-devel.x86_64 0:50.1.2-15.el7 will be installed
---> Package tcl-devel.x86_64 1:8.5.13-8.el7 will be installed
---> Package texinfo-tex.x86_64 0:5.1-5.el7 will be installed
--> Processing Dependency: texinfo = 5.1-5.el7 for package: texinfo-tex-5.1-5.el7.x86_64
--> Processing Dependency: tex(epsf.tex) for package: texinfo-tex-5.1-5.el7.x86_64
---> Package tk-devel.x86_64 1:8.5.13-6.el7 will be installed
--> Processing Dependency: libXft-devel for package: 1:tk-devel-8.5.13-6.el7.x86_64
---> Package tre-devel.x86_64 0:0.8.0-18.20140228gitc2f5d13.el7 will be installed
--> Running transaction check
---> Package R-java-devel.x86_64 0:3.5.1-1.el7 will be installed
--> Processing Dependency: java-devel for package: R-java-devel-3.5.1-1.el7.x86_64
Package 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64 is obsoleted by 2000:gd-jdk8-1.8.0_92-fcs.x86_64 which is already installed
---> Package libXft-devel.x86_64 0:2.3.2-2.el7 will be installed
--> Processing Dependency: pkgconfig(xrender) for package: libXft-devel-2.3.2-2.el7.x86_64
--> Processing Dependency: pkgconfig(freetype2) for package: libXft-devel-2.3.2-2.el7.x86_64
--> Processing Dependency: pkgconfig(fontconfig) for package: libXft-devel-2.3.2-2.el7.x86_64
---> Package libquadmath-devel.x86_64 0:4.8.5-28.el7_5.1 will be installed
---> Package libstdc++-devel.x86_64 0:4.8.5-28.el7_5.1 will be installed
---> Package libxcb-devel.x86_64 0:1.12-1.el7 will be installed
--> Processing Dependency: pkgconfig(xau) >= 0.99.2 for package: libxcb-devel-1.12-1.el7.x86_64
---> Package texinfo.x86_64 0:5.1-5.el7 will be installed
--> Processing Dependency: perl(Locale::Messages) for package: texinfo-5.1-5.el7.x86_64
---> Package texlive-epsf.noarch 2:svn21461.2.7.4-38.el7 will be installed
---> Package xorg-x11-proto-devel.noarch 0:7.7-20.el7 will be installed
--> Running transaction check
---> Package R-java-devel.x86_64 0:3.5.1-1.el7 will be installed
--> Processing Dependency: java-devel for package: R-java-devel-3.5.1-1.el7.x86_64
Package 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64 is obsoleted by 2000:gd-jdk8-1.8.0_92-fcs.x86_64 which is already installed
---> Package fontconfig-devel.x86_64 0:2.10.95-11.el7 will be installed
--> Processing Dependency: pkgconfig(expat) for package: fontconfig-devel-2.10.95-11.el7.x86_64
---> Package freetype-devel.x86_64 0:2.4.11-15.el7 will be installed
---> Package libXau-devel.x86_64 0:1.0.8-2.1.el7 will be installed
---> Package libXrender-devel.x86_64 0:0.9.10-1.el7 will be installed
---> Package perl-libintl.x86_64 0:1.20-12.el7 will be installed
--> Running transaction check
---> Package R-java-devel.x86_64 0:3.5.1-1.el7 will be installed
--> Processing Dependency: java-devel for package: R-java-devel-3.5.1-1.el7.x86_64
Package 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64 is obsoleted by 2000:gd-jdk8-1.8.0_92-fcs.x86_64 which is already installed
---> Package expat-devel.x86_64 0:2.1.0-10.el7_3 will be installed
--> Finished Dependency Resolution
Error: Package: R-java-devel-3.5.1-1.el7.x86_64 (epel)
Requires: java-devel
Available: 1:java-1.7.0-openjdk-devel-1.7.0.171-2.6.13.2.el7.x86_64 (centos-base-prod)
java-devel = 1:1.7.0
Available: 1:java-1.7.0-openjdk-devel-1.7.0.181-2.6.14.5.el7.x86_64 (centos-updates-prod)
java-devel = 1:1.7.0
Available: 1:java-1.7.0-openjdk-devel-1.7.0.181-2.6.14.8.el7_5.x86_64 (centos-updates-prod)
java-devel = 1:1.7.0
Available: 1:java-1.7.0-openjdk-devel-1.7.0.191-2.6.15.4.el7_5.x86_64 (centos-updates-prod)
java-devel = 1:1.7.0
Available: 1:java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.i686 (centos-base-prod)
java-devel = 1:1.8.0
Available: 1:java-1.8.0-openjdk-devel-1.8.0.171-7.b10.el7.i686 (centos-updates-prod)
java-devel = 1:1.8.0
Available: 1:java-1.8.0-openjdk-devel-1.8.0.171-8.b10.el7_5.i686 (centos-updates-prod)
java-devel = 1:1.8.0
Available: 1:java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.i686 (centos-updates-prod)
java-devel = 1:1.8.0
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
我发现了另外一条SO帖子,提示我尝试使用颞侧肌:
sudo R CMD javareconf
哪个输出结果:
[myname@myip ~]$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_92
Java home path : /usr/java/jdk1.8.0_92/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I/usr/java/jdk1.8.0_92/jre/../include -I/usr/java/jdk1.8.0_92/jre/../include/linux -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c conftest.c -o conftest.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o conftest.so conftest.o -L/usr/java/jdk1.8.0_92/jre/lib/amd64/server -ljvm -L/usr/lib64/R/lib -lR
JAVA_HOME : /usr/java/jdk1.8.0_92/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 /usr/lib64/R
Done.
但是,在此之后我尝试再次安装R-devel,但结果没有改变。
Google搜索将我带到了几篇有关在OSX上安装R的博客文章中,例如http://conjugateprior.org/2014/12/r-java8-osx/
该帖子中的步骤没有帮助。该帖子的第三步是尝试install.packages('rJava', type='source')
但是,由于没有R-devel我无法安装软件包,因此我得到一个非零的退出状态:
install.packages('rJava', type='source')
Installing package into ‘/home/rstudio/mylibs’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-10.tar.gz'
Content type 'application/x-gzip' length 672577 bytes (656 KB)
==================================================
downloaded 656 KB
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc -m64 -std=gnu99 supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver : '/usr/bin/jar'
compiler : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags : '-I/usr/java/jdk1.8.0_92/jre/../include -I/usr/java/jdk1.8.0_92/jre/../include/linux'
java libs : '-L/usr/java/jdk1.8.0_92/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether -Xrs will be used... yes
checking whether JNI programs can be compiled... yes
checking JNI data types... ok
checking whether JRI should be compiled (autodetect)... yes
checking whether debugging output should be enabled... no
checking whether memory profiling is desired... no
checking whether threads support is requested... no
checking whether callbacks support is requested... no
checking whether JNI cache support is requested... no
checking whether headless init is enabled... no
checking whether JRI is requested... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/zzz.R
config.status: creating src/config.h
=== configuring in jri (/tmp/Rtmp5FuZFE/R.INSTALL645818d0b0f8/rJava/jri)
configure: running /bin/sh ./configure --disable-option-checking '--prefix=/usr/local' --cache-file=/dev/null --srcdir=.
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc -m64 -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking Java version... 1.8.0_92
checking whether /usr/bin/javah actually works... yes
checking for target flags... -target 1.4 -source 1.4
checking whether Java interpreter works... checking whether JNI programs can be compiled... yes
checking whether JNI programs can be run... yes
checking JNI data types... ok
checking whether Rinterface.h exports R_CStackXXX variables... no
checking whether Rinterface.h exports R_SignalHandlers... no
configure: creating ./config.status
config.status: creating src/Makefile
config.status: creating Makefile
config.status: creating run
config.status: creating src/config.h
** libs
Warning: R include directory is empty -- perhaps need to install R-devel.rpm or similar
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I. -I/usr/java/jdk1.8.0_92/jre/../include -I/usr/java/jdk1.8.0_92/jre/../include/linux -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c Rglue.c -o Rglue.o
In file included from Rglue.c:2:0:
rJava.h:23:15: fatal error: R.h: No such file or directory
#include <R.h>
^
compilation terminated.
make: *** [Rglue.o] Error 1
ERROR: compilation failed for package ‘rJava’
* removing ‘/home/rstudio/mylibs/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp4W5Egm/downloaded_packages’
This SO post有更多详细信息,但它最后指出了here上的解决方案。可接受的答案是针对OSX,我不确定等效的Linux CentOs7命令是什么?
如何使用Java 1.8在Linux centos7上使用R-devel设置R?