R CMD javareconf找不到jni.h [英] R CMD javareconf not finding jni.h

查看:65
本文介绍了R CMD javareconf找不到jni.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在Anaconda的基于debian(jessie)的Docker容器中安装rJava.

I'm trying to install rJava in a docker container based on debian (jessie) with Anaconda.

我是root

$ apt-get update  && apt-get install -y --no-install-recommends \
  default-jdk default-jre libicu-dev 

然后

$ R CMD javareconf 
Java interpreter : /usr/lib/jvm/jdk1.8.0_121/jre/bin/java
Java version     : 1.8.0_121
Java home path   : /usr/lib/jvm/jdk1.8.0_121
Java compiler    : /usr/lib/jvm/jdk1.8.0_121/bin/javac
Java headers gen.: /usr/lib/jvm/jdk1.8.0_121/bin/javah
Java archive tool: /usr/lib/jvm/jdk1.8.0_121/bin/jar

trying to compile and link a JNI program 
detected JNI cpp flags    : -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/opt/conda/lib/R/include -DNDEBUG -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux -I/opt/conda/include    -fpic  -I/opt/conda/include  -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
 #include <jni.h>
                 ^
compilation terminated.
/opt/conda/lib/R/etc/Makeconf:133: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program


JAVA_HOME        : /usr/lib/jvm/jdk1.8.0_121
Java library path: 
JNI cpp flags    : 
JNI linker flags : 
Updating Java configuration in /opt/conda/lib/R
Done.

但是jni.h在JDK中是正确的:

But jni.h is right in the JDK:

# find /usr/lib/jvm/jdk1.8.0_121/ -name jni.h
/usr/lib/jvm/jdk1.8.0_121/include/jni.h

看起来好像不是 javareconf 在找到它.而且,如果我查看可以使用javareconf设置的所有变量(例如JAVA_HOME),则看不到设置JNI cpp标志的能力,这需要正确的包含.

It just doesn't look like javareconf is finding it. And, if I look at all the variables I could set with javareconf, like JAVA_HOME, I don't see the ability to set JNI cpp flags, which would need the right includes.

我已经看到帖子问题,但没有解决方案.

I've seen various posts around the Internet of this problem, but no solutions.

推荐答案

我不确定此处是否已确认答案,但我会向所有人指出此文章,作者:安德鲁·科利尔(Andrew Collier).

I'm not sure if an answer has been confirmed here, but I would point everyone to this article by Andrew Collier.

他的建议:

(1)更新所有存储库

sudo apt update -y

(2)确保已安装JRE和JDK 8

sudo apt install -y openjdk-8-jdk openjdk-8-jre

(3)然后,正如许多用户已经说过的那样,将R指向具有JDK 8显式路径的java

sudo R CMD javareconf JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/

只要在/include目录中具有所有必需的已编译内容,特定的Java包就没有太大关系.

The specific Java package does not matter too much as long as it has all the necessary compiled contents within the /include directory.

user@laptop:~$ ls /usr/lib/jvm/java-8-openjdk-amd64/include/
classfile_constants.h  jdwpTransport.h  jvmticmlr.h  linux
jawt.h                 jni.h            jvmti.h

有关此内容的更多信息,我建议 ​​ 如何以便找到jni.h? 以便正确定位/编译此目录.

For more on this, I would recommend how to make jni.h be found? for going about locating/compiling this directory correctly.

这篇关于R CMD javareconf找不到jni.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆