I have some problems with native functions in HaikuVM.
I have the following simple code example, where i want to make the blink part in C instead of in Java.
packagemain;publicclassBlink{publicstaticnativevoidMain();publicstaticnativevoidnBlink();publicstaticvoidmain(String[]args){// Data direction of I/O-Port. Main();while(true){nBlink();}}}
The functions gets generated in haikuJNI.c as mentioned in the tutorial, e.g.
But the block with the "TODO" comment always gets overwritten when compling. What am I doing wrong? I Also tried the @NativeCFunction flag, but it did not generate any functions in nativeCFunctions.cpp
What am I doing wrong, and also have can i use includes in these native functions?
Thanks in advance.
I'm also getting the following error:
./HaikuVM/utility/nativeCFunctions.o: In function `native_Blink_nBlink_V':nativeCFunctions.cpp:(.text.native_Blink_nBlink_V+0x4): undefined reference to `nBlink'
Last edit: Peter 2016-01-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What you see in 'haikuJNI.c' is a HaikuVM generated blueprint of the JNI wrapper. It's made to copy&past it into some C file of your project directory as stated in this tutorial: http://haiku-vm.sourceforge.net/#[[JNI%20simple]]
(The file 'haikuJNI.c' is not made for compilation with a C compiler. It's just made for you, as a copy&past source and therefore is overwritten/generated on any run of HaikuVM.)
In your case try this.
Make some directory 'firstJNIProject':
mkdir firstJNIProject
mkdir firstJNIProject\myFirstJNIfiles
cd firstJNIProject
And yes, in this state you get some 'undefined reference' error like:
./HaikuVM/JVM.o:(.progmem.data+0x2d8): undefined reference to `native_main_Blink_Main_V'./HaikuVM/JVM.o:(.progmem.data+0x2db): undefined reference to `native_main_Blink_nBlink_V'
But now it's happy copy&past time. Copy the part you mentioned from 'haikuJNI.c' into (let's say) file 'firstJNIProject\myFirstJNIfiles\myNativeCFunctions.cpp'. After some additional editing, your C++ file 'myNativeCFunctions.cpp' should look like this:
I have some problems with native functions in HaikuVM.
I have the following simple code example, where i want to make the blink part in C instead of in Java.
The functions gets generated in haikuJNI.c as mentioned in the tutorial, e.g.
But the block with the "TODO" comment always gets overwritten when compling. What am I doing wrong? I Also tried the @NativeCFunction flag, but it did not generate any functions in nativeCFunctions.cpp
What am I doing wrong, and also have can i use includes in these native functions?
Thanks in advance.
I'm also getting the following error:
Last edit: Peter 2016-01-24
Hello Peter,
thank you for using HaikuVM.
What you see in 'haikuJNI.c' is a HaikuVM generated blueprint of the JNI wrapper. It's made to copy&past it into some C file of your project directory as stated in this tutorial: http://haiku-vm.sourceforge.net/#[[JNI%20simple]]
(The file 'haikuJNI.c' is not made for compilation with a C compiler. It's just made for you, as a copy&past source and therefore is overwritten/generated on any run of HaikuVM.)
In your case try this.
Make some directory 'firstJNIProject':
Haikufy your Java program:
And yes, in this state you get some 'undefined reference' error like:
But now it's happy copy&past time. Copy the part you mentioned from 'haikuJNI.c' into (let's say) file 'firstJNIProject\myFirstJNIfiles\myNativeCFunctions.cpp'. After some additional editing, your C++ file 'myNativeCFunctions.cpp' should look like this:
Give it a try:
Now all 'undefined reference' errors should be resolved. You are ready to fill the "TODO" comments with your code.
Is this of some help for you?
Last edit: genom2 2016-01-25