Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in the installation of rJava: Cannot compile a simple JNI program #321

Closed
jessijessi opened this issue Mar 7, 2024 · 2 comments
Closed

Comments

@jessijessi
Copy link

Hi,
I have tried to install the rJava package in R 4.3.1 using install.packages('rJava') and encountered an error. My operating system is Red Hat/Centos 8 and the openjdk version is "16.0.2" 2021-07-20.
The error is the following:

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
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 accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -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 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.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/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 JVM will be loaded dynamically... no
checking whether JNI programs can be compiled... configure: error: Cannot compile a simple JNI program. See config.log for details.


Make sure you have Java Development Kit installed and correctly registered in R.
If in doubt, re-run "R CMD javareconf" as root.

Unfortunately, I haven't the permission of sudo thus I cannot launch the command R CMD javareconf" as root.
I tried to find the config.log file but I didn't find it, Does anyone know where is this file?

How can I solve the issue?

Thank you,
Best regards

Jessica

@jessijessi jessijessi changed the title Issue in the installation of rJavs: Cannot compile a simple JNI program Issue in the installation of rJava: Cannot compile a simple JNI program Mar 7, 2024
@s-u
Copy link
Owner

s-u commented Mar 7, 2024

Please see https://github.com/s-u/rJava - scroll down to the Troubleshooting section for Linux. config.log is next to configure in your build directory. If you don't have write permission to the R installation, you can use -e to start a shell with the configured variables set as environment variables.

@s-u s-u closed this as completed Mar 7, 2024
@jessijessi
Copy link
Author

Thank you for the suggestions, I have launched "R CMD javareconf -e" and I found this error:

Java interpreter : /usr/bin/java
Java version     : 1.8.0_282
Java home path   : /share/apps/spack/latest-2024-01-17/linux-centos8-skylake_avx512/gcc-8.4.1/openjdk-11.0.2-fu22jzad3otvgxftqlynpxiqt4emtqiq
Java compiler    : /share/apps/spack/latest-2024-01-17/linux-centos8-skylake_avx512/gcc-8.4.1/openjdk-11.0.2-fu22jzad3otvgxftqlynpxiqt4emtqiq/bin/javac
Java headers gen.:
Java archive tool: /share/apps/spack/latest-2024-01-17/linux-centos8-skylake_avx512/gcc-8.4.1/openjdk-11.0.2-fu22jzad3otvgxftqlynpxiqt4emtqiq/bin/jar

trying to compile and link a JNI program
detected JNI cpp flags    :
detected JNI linker flags :
using C compiler: ‘gcc (GCC) 10.2.0’
gcc -I"/opt/R/4.3.1/lib/R/include" -DNDEBUG   -I///share/apps/spack/latest-2024-01-17/linux-centos8-skylake_avx512/gcc-8.4.1/openjdk-11.0.2-fu22jzad3otvgxftqlynpxiqt4emtqiq/include    -fpic  -g -O2  -c conftest.c -o conftest.o
In file included from conftest.c:1:
///share/apps/spack/latest-2024-01-17/linux-centos8-skylake_avx512/gcc-8.4.1/openjdk-11.0.2-fu22jzad3otvgxftqlynpxiqt4emtqiq/include/jni.h:45:10: fatal error: jni_md.h: No such file or directory
   45 | #include "jni_md.h"
      |          ^~~~~~~~~~
compilation terminated.
make: *** [/opt/R/4.3.1/lib/R/etc/Makeconf:191: conftest.o] Error 1
Unable to compile a JNI program

The following Java variables have been exported:
JAVA_HOME JAVA JAVAC JAVAH JAR JAVA_LIBS JAVA_CPPFLAGS JAVA_LD_LIBRARY_PATH
Running: /bin/bash

Do you know how can I solve the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants