Q
Québec
Hi,
Should be simple after all. I tried this with the help of CoreJava2 vol2.
serie.o(.text+0x25):serie.c: undefined reference to `GetStringChars'
serie.o(.text+0x4e):serie.c: undefined reference to `GetStringLength'
serie.o(.text+0xc4):serie.c: undefined reference to `NewStringUTF'
==========
//serial.c
#include "Serial.h"
#include <stdio.h>
JNIEXPORT jstring JNICALL Java_Serial_numero
(JNIEnv *env, jobject jobjc, jstring jstr){
jboolean *iscopy;
jstring ret;
jsize len;
const char* fmt;
fmt = (*env)-->GetStringChars(env, jstr, iscopy);
len = (*env)-->GetStringLength(env, jstr);
printf("%d", len);
printf("%s", fmt);
printf("%s", ret);
fflush(stdout);
ret = (*env)-->NewStringUTF(env, fmt);
return ret;
}
---------------
public class Serial
{
public static void main(String[] args)
{
Serial serie = new Serial();
System.out.println(serie.numero("Jean"));
}
public native int numero(String one);
static
{
System.loadLibrary("serial");
}
}
-------------
Should be simple after all. I tried this with the help of CoreJava2 vol2.
serie.o(.text+0x25):serie.c: undefined reference to `GetStringChars'
serie.o(.text+0x4e):serie.c: undefined reference to `GetStringLength'
serie.o(.text+0xc4):serie.c: undefined reference to `NewStringUTF'
==========
//serial.c
#include "Serial.h"
#include <stdio.h>
JNIEXPORT jstring JNICALL Java_Serial_numero
(JNIEnv *env, jobject jobjc, jstring jstr){
jboolean *iscopy;
jstring ret;
jsize len;
const char* fmt;
fmt = (*env)-->GetStringChars(env, jstr, iscopy);
len = (*env)-->GetStringLength(env, jstr);
printf("%d", len);
printf("%s", fmt);
printf("%s", ret);
fflush(stdout);
ret = (*env)-->NewStringUTF(env, fmt);
return ret;
}
---------------
public class Serial
{
public static void main(String[] args)
{
Serial serie = new Serial();
System.out.println(serie.numero("Jean"));
}
public native int numero(String one);
static
{
System.loadLibrary("serial");
}
}
-------------