在R 2.14下安装rJava并导致OpenSUSE失败

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在R 2.14下安装rJava并导致OpenSUSE失败相关的知识,希望对你有一定的参考价值。

我正在尝试在OpenSUSE 11.3的R 2.14.1-9.1上安装rJava软件包。我已经看到this问题,但这是针对Ubuntu的。我已经安装了Sun JDK并重新配置了系统以使用它。

admin@linux-nb3w:~> java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode)
admin@linux-nb3w:~> 

编辑1:更新了JDK和JRE。现在,当我运行install.packages("rJava")时,会有一些略有不同的错误,我得到以下输出错误(新错误已发布,并且结尾在bold中):

> install.packages("rJava")
Installing package(s) into ‘/home/admin/R/i686-pc-linux-gnu-library/2.14’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://ftp.iitm.ac.in/cran/src/contrib/rJava_0.9-3.tar.gz'
Content type 'application/x-gzip' length 537153 bytes (524 Kb)
opened URL
==================================================
downloaded 524 Kb

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...                                                                                                                                                                                                                                          
checking for suffix of object files... o                                                                                                                                                                                                                                       
checking whether we are using the GNU C compiler... yes                                                                                                                                                                                                                        
checking whether gcc -std=gnu99 accepts -g... yes                                                                                                                                                                                                                              
checking for gcc -std=gnu99 option to accept ISO C89... none needed                                                                                                                                                                                                            
checking how to run the C preprocessor... gcc -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 -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/lib/jvm/java-1.6.0-sun-1.6.0/jre/../include -I/usr/lib/jvm/java-1.6.0-sun-1.6.0/jre/../include/linux'                                                                                                                                                    
java libs   : '-L/usr/lib/jvm/java-1.6.0-sun-1.6.0/jre/lib/i386/client -L/usr/lib/jvm/java-1.6.0-sun-1.6.0/jre/lib/i386 -L/usr/lib/jvm/java-1.6.0-sun-1.6.0/jre/../lib/i386 -L/usr/java/packages/lib/i386 -L/lib -L/usr/lib -ljvm'
checking whether JNI programs can be compiled... yes
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/admin/R/i686-pc-linux-gnu-library/2.14/rJava’

The downloaded packages are in
        ‘/tmp/RtmpIFKEha/downloaded_packages’
Warning message:
In install.packages("rJava") :
  installation of package ‘rJava’ had non-zero exit status
> 

新错误行:

正在检查JNI数据类型...配置:错误:一种或多种JNI类型与相应的本机类型不同。您可能需要使用非标准的编译器标志或其他编译器才能解决此问题。

我确实将R CMD javareconf作为root运行。它将cpp标志字段留空。我知道这是失败的原因之一,但不知道如何解决。

我已经尝试使用带有dependencies = TRUE选项的安装命令,并且还明确指定了repo(例如repo =“ blah blah”)。什么都没用。

我不知道如何为OpenSUSE进行更新。但是,看起来似乎没有简单的方法可以为SUSE做到这一点,与Ubuntu不同,Ubuntu的步骤明确给出了here

感谢您的帮助。

答案

尽管正在运行update-alternatives --config javac,但尚未更新JAVA_HOME。因此,我手动设置它:

export JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun-1.6.0.u6

您必须以root的身份运行上述命令。

然后运行R CMD javareconf。取得了一些进展,安装超出了先前失败的范围。但这仍然给我以下错误:

Warning: R include directory is empty -- perhaps need to install R-devel.rpm or similar
gcc -std=gnu99 -I/usr/lib/R/include -I. -I/usr/lib/jvm/java-1.6.0-sun-1.6.0/include -I/usr/lib/jvm/java-1.6.0-sun-1.6.0/include/linux -I/usr/local/include    -fpic  -fomit-frame-pointer -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -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
compilation terminated.
make: *** [Rglue.o] Error 1
ERROR: compilation failed for package ‘rJava’
* removing ‘/usr/lib/R/library/rJava’

The downloaded packages are in
        ‘/tmp/Rtmp3zqlgI/downloaded_packages’
Updating html index of packages in '.Library'
Making packages.html  ... done
Warning message:
In install.packages("rJava") :
  installation of package ‘rJava’ had non-zero exit status
>

然后按照错误中的建议,安装R-devel-rpm,如下所示:

zypper install R-patched R-patched-devel

(以root的身份运行上述命令] >>

此后,运行R和"install.package("rJava")"有效。

几乎5个小时的挫败感和4票赞成的真正问题.....但终于松了一口气! :)

另一答案
# R CMD javareconf
Updating Java configuration in /usr/lib/R Done.

> install.packages("rJava")
* DONE (rJava)
另一答案

很棒。在Gentoo下也是一样。做

以上是关于在R 2.14下安装rJava并导致OpenSUSE失败的主要内容,如果未能解决你的问题,请参考以下文章

R:无法安装 rJava;啥是 r-api-3.4?

R语言中 安装rJava 和Rwordseg

使 rJava 或 R 使用不同的(以前的)Java 版本

怎么安装r语言中的rjava包

R 安装包遇到问题 loadNamespace()里算'rJava'时.onLoad失败了 rJava 包的安装与载入

解惑rJava R与Java的快速通道