trouble installing JRI (R to java) - java

I'm wondering if anyone has experience with my error message or has any advice.
When I run the ./configure file it runs with no error. When I run the make file I get
make -C src JRI.jar
gcc-4.2 -arch x86_64 -std=gnu99 -c -o Rengine.o Rengine.c -g -Iinclude -g -O2 -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include/. -fno-common -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include/. -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64
Rengine.c: In function ‘Java_org_rosuda_JRI_Rengine_rniParse’:
Rengine.c:89: error: too few arguments to function ‘R_ParseVector’
Rengine.c: In function ‘Java_org_rosuda_JRI_Rengine_rniRunMainLoop’:
Rengine.c:181: warning: implicit declaration of function ‘run_Rmainloop’
Rengine.c: In function ‘Java_org_rosuda_JRI_Rengine_rniGetList’:
Rengine.c:313: warning: implicit declaration of function ‘jri_error’
Rengine.c: In function ‘Java_org_rosuda_JRI_Rengine_rniStop’:
Rengine.c:377: warning: implicit declaration of function ‘getpid’
make[1]: *** [Rengine.o] Error 1
make: *** [src/JRI.jar] Error 2
I've seen the same or similar question asked on other forums but it didn't seem that anyone had there question answered. Wondering if anyone knew what this means on stackoverflow.

Try using the rJava distribution instead (JRI is now part of rJava).

Related

JDK9 NetBeans Dev - compile error during JNI Tutorial

I have searched the entire web throughly for almost two days now and couldn't come up with a solution to my problem. I hope you guys can help me.
This might be a little specific but I am sure sooner or later others will experience the same problems.
I am currently using NetBeans Dev (Build 201803200002) with Java JDK 9.0.4 on a Windows 10, 64-bit system.
I was working through this JNI tutorial:
https://cnd.netbeans.org/docs/jni/beginning-jni-win.html
Almost at the end, below figure 13, you are supposed to build the project HelloWorldNative (in my case it is called JNITestNative).
But I always get the following error message:
cd 'D:\NetBeans\projects\JNITestNative'
C:\Programme\cygwin\bin\make.exe -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/d/NetBeans/projects/JNITestNative'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/JNITestNative.dll
make[2]: Entering directory '/cygdrive/d/NetBeans/projects/JNITestNative'
mkdir -p build/Debug/Cygwin-Windows
rm -f "build/Debug/Cygwin-Windows/JNITest.o.d"
gcc -mno-cygwin -Wl,--add-stdcall-alias shared -m32 -c -g -I/cygdrive/C/Program\ Files/Java/jdk-9.0.4/include -I/cygdrive/C/Program\ Files/Java/jdk-9.0.4/include/win32 -MMD -MP -MF "build/Debug/Cygwin-Windows/JNITest.o.d" -o build/Debug/Cygwin-Windows/JNITest.o JNITest.c
gcc: error: shared: No such file or directory
gcc: error: unrecognized command line option '-mno-cygwin'; did you mean '-mno-clwb'?
nbproject/Makefile-Debug.mk:66: recipe for target 'build/Debug/Cygwin-Windows/JNITest.o' failed
make[2]: *** [build/Debug/Cygwin-Windows/JNITest.o] Error 1
make[2]: Leaving directory '/cygdrive/d/NetBeans/projects/JNITestNative'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/d/NetBeans/projects/JNITestNative'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
NetBeans seems to be missing a file which I am expecting it to generate in the first place - JNITest.o
I checked the directories ...jdk-9.0.4/include, ...jdk9.0.4/include/win32 and ...Debug/Cygwin-Windows.
All of them exist, but the files JNITest.o.d or JNITest.o do not.
I tried to replace "cygwin" by "clwb" as suggested in the second error message, but the first error still occurs.
According to some sources in the internet I also removed the whole part "-mno-cygwin" from the additional options but the first error still occurs.
According to some other sources in the internet I added my ...cygwin/bin directory to the include directories, but this did not improve anything.
I have absolutely no idea how to solve this or how to search for other potential solutions anymore.
I hope anyone here can help.
The correct answer was stated by Jorn Vernee in his comment.
A '-' was missing before the argument "shared".
Thank you for that.
For anyone else who might be experiencing this problem, let me sum up how I got from here to a successful build.
According to this and this I added three code lines for the definition of data type __int64, so now my JNITest.c looks like this:
#ifdef __CYGWIN__
#define __int64 long long
#endif
#include <jni.h>
#include <stdio.h>
#include "JNITest.h"
JNIEXPORT void JNICALL Java_com_plaettner_jnitest_JNITest_nativePrint
(JNIEnv *env, jobject obj)
{
printf("\nHello World from C\n");
}
Next I added the packages "mingw64-i686-gcc-core: GCC for Win32" and "mingw64-i686-gcc-g++: GCC for Win32" to my Cygwin.
In NetBeans options - C/C++ - Build Tools I then changed the C and C++ Compiler from gcc/g++ to i686-w64-mingw32-gcc/g++ respectively.
In the project properties in the categories Build - C Compiler/C++ Compiler I changed the additional options from "-mno-cygwin -Wl,--add-stdcall-alias -shared -m32" to "-Wl,--add-stdcall-alias -shared" and added my ...cygwin/bin directory to the include directories.
This leads to a successful build already. Anyway I added "-m32" to the additional options again and changed c/c++ Compiler back to gcc/g++ to keep compliance to the tutorial.
Now this leads to a successful build as well, although it didn't before.
Removing the ...cygwin/bin directory from the include directories leads to a failed build again and the whole process has to be repeated.
At least for me it worked this way.

fatal error: jni.h: No such file or directory Netbeans IDE

I want to learn that how we can call a java function from C++,after following some links i came to know that we need to add following header file in C++ file
#include <jni.h>
but when I added this file in C++ file in Netbeans IDE I got following error
fatal error: jni.h: No such file or directory
How can this error be removed, I am just beginner in JNI.
I went through previous questions asked at stackoverflow but was not able to go through the Problem.
Here is my comile output:
"/C/MinGW/MSYS/1.0/bin./make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
"/C/MinGW/MSYS/1.0/bin./make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/jnidemo.exe
make.exe[2]: Entering directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
main.cpp:9:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.
make.exe[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make.exe[2]: Leaving directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
make.exe": *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
You are compiling with MinGW without including Java headers, thats why it complains about not found
Try to add this option to your compilation command -I"c:/path/to/jdk/include" -I"c:/path/to/jdk/include/win32" -D__int64="long long".
The last option is to avoid the error caused because windows compiler uses the type __int64 and gcc uses long long.
Have you looked at the Netbeans JNI tutorial?
It goes through everything you should need to do in pretty good detail.

linux 64bit - jni linking error

I'm trying to get a working example of calling Java from C using JNI on ubuntu 64bit.
The code from: calling java function from c using jni I am compiling using:
gcc test.c -I/usr/lib/jvm/java-1.7.0-openjdk-amd64/include -I/usr/lib/jvm/java-1.7.0-openjdk-amd64/include/linux -c
gcc test.o -L/usr/lib/jvm/java-1.7.0-openjdk/amd64/jre/lib/amd64/server/ -ljvm -o jniTest
This doesnt generate any errors but if I try ldd jniTest I get the following:
linux-vdso.so.1 => (0x00007fffe55d5000)
libjvm.so => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f85f2928000)
/lib64/ld-linux-x86-64.so.2 (0x00007f85f2d0a000)
And if I try ./jniTest it gives this error:
test.o: In function `create_vm':
test.c:(.text+0x35): undefined reference to `JNI_CreateJavaVM'
collect2: error: ld returned 1 exit status
With the -L/usr/lib/jvm/java-1.7.0-openjdk/amd64/jre/lib/amd64/server/ you tell the linker where to find libjvm.so. At runtime you will need to do the same (http://linux.die.net/man/8/ld.so). And you'll also need the parent directory because other needed libs are in there. One way to do this is by specifying it on the command line: LD_LIBRARY_PATH=/usr/lib/jvm/java-1.7.0-openjdk/amd64/jre/lib/amd64/server:/usr/lib/jvm/java-1.7.0-openjdk/amd64/jre/lib/amd64 ./jniTest.
A way to get around the need to specify the path is to not link to libjvm.so at all but to find it at runtime and then use the functions in dlfcn.h (http://linux.die.net/man/3/dlopen, http://linux.die.net/man/3/dlsym) to use it.

Compiling JNI Example

I am trying to use JNI to call a Java program from a C++ program. A supplier has put in place some phone apparatus and it only uses C++. I want to write a Screen Popper but don't want to do it in C++ so therefore want to pass across the event of the phone call coming in and the number to a Java routine to handle. I am using Netbeans as it makes the coding easier (usually!). I have not done C++ before which is why I want to escape to Java ASAP!
I am following instructions here: http://www.ibm.com/developerworks/java/tutorials/j-jni/j-jni.html
Which seem to set out how to call a Java routine from C++ but I cannot get it to compile. I have got as far as I with lots of help from this site but now I'm stumped.
I have added the '-D__int64=long long' switch to the compiler options for the project and added the Java libraries to the Application include paths. I have reparsed the code using code assistance. But now I'm left with this error:
make[1]: Entering directory '/cygdrive/f/Javadev/Sample2'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/sample2.exe
make[2]: Entering directory '/cygdrive/f/Javadev/Sample2'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f build/Debug/Cygwin_4.x-Windows/main.o.d
g++.exe -D__int64=long long -c -g -I/cygdrive/C/Program\ Files\ \(x86\)/Java/jdk1.6.0_33/include/win32 -I/cygdrive/C/Program\ Files\ \(x86\)/Java/jdk1.6.0_33/include -MMD -MP -MF build/Debug/Cygwin_4.x-Windows/main.o.d -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
nbproject/Makefile-Debug.mk:65: recipe for target 'build/Debug/Cygwin_4.x-Windows/main.o' failed
make[2]: Leaving directory '/cygdrive/f/Javadev/Sample2'
nbproject/Makefile-Debug.mk:58: recipe for target '.build-conf' failed
make[1]: Leaving directory '/cygdrive/f/Javadev/Sample2'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
g++: error: long: No such file or directory
make[2]: *** [build/Debug/Cygwin_4.x-Windows/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
All source files are under F:\javadev, Sample2 is C++ and Sample3 is Java. Is there something else I need to include from Cygwin? It seems to say there is a problem with 'long' but that only really occurs in the switch and without it it fails even more catastrophically, saying that __int64 does not have a type.

How to build javafuse on Ubuntu?

I'm trying to implement the JavaFuse project but when I execute the make command I'm getting this error:
gcc -shared build/contextClass.o build/conninfoClass.o build/javafuse_jni.o build/statvfsClass.o build/fsClass.o build/utimebufClass.o build/fileinfoClass.o build/statClass.o -o build/libjavafuse.so
Error:
build/contextClass.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make: * [libjavafuse.so] Error 1
I'm using Ubuntu.
Could anyone please suggest what is the problem?
I recommend fuse-jna, it's a project that I've used and it doesn't need to be compiled and also, it's alive and you may find it here fuse-jna. hope it'll help you

Categories

Resources