from java how to use a c native library which takes a structure pointer as an argument
===

I have a c library which takes a structure pointer as an argument in one of its method and also returns the structure pointer. I want to use this library without changing anything into it from java. For this one way which i have used is to create a wrapper function in c which will call the c native library but it is not working. Below is the code for my project:

    Java code : 

    package com.kpit.myfirstndkapp;

    import android.app.Activity;

    class myclass {
    int a = 1;
    int b = 2;
	
    public native void callTostructJNI();

    static {
    System.loadLibrary("sum_jni");
    System.loadLibrary("wrapper_jni");
     
    }
    }
    public class sum extends Activity {
	
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sum);
	      
    myclass myobject = new myclass(); 
      
    System.out.println("calling the jni native method using findclass");
	         
    myobject.callTostructJNI();
	         
    System.out.println("returned from jni native method one");

    System.out.format(" a = %d%n....", myobject.a);
    System.out.format("b =  %d%n...", myobject.b);
	         
    }
    }

Wrapper function which i have written in a seperate c library : 

    #include <stdio.h>
    #include <stdlib.h>
    #include <jni.h>
    #include <wrapper.h>

    void Java_com_kpit_myfirstndkapp_myclass_callTostructJNI(JNIEnv* env,
    jobject obj)
    {
    jclass myclass;
    struct mystruct temp;
    struct mystruct* strptr;

    jclass localRefCls =
    (*env)->FindClass(env, "com/kpit/myfirstndkapp/myclass");
    myclass = (*env)->NewGlobalRef(env, localRefCls);

    printf(" Inside the JNI native method \n");
    strptr = change_values_of_integer((struct mystruct *)myclass);
    }

Wrapper.h file is as shown below :

    #include <stdio.h>
    #include <stdlib.h>
    #include <jni.h>

    struct mystruct {
    int c;
    int d;
    };

    extern struct mystruct *change_values_of_integer( struct mystruct* str);

and the c native library code is like below :

    #include <stdio.h>
    #include <stdlib.h>
    #include <jni.h>
    #include <wrapper.h>

    struct mystruct *change_values_of_integer(struct mystruct* str)
    {
    str->c = 3;
    str->d = 4;

    return str;
    }

I get the below error log while running the application: 

    07-31 08:59:35.806: D/dalvikvm(572): Trying to load lib /data/data/com.kpit.myfirstndkapp  /lib/libwrapper_jni.so 0x4129d858
    07-31 08:59:35.806: D/dalvikvm(572): Added shared lib /data/data/com.kpit.myfirstndkapp/lib/libwrapper_jni.so 0x4129d858
    07-31 08:59:35.816: D/dalvikvm(572): No JNI_OnLoad found in /data/data/com.kpit.myfirstndkapp/lib/libwrapper_jni.so 0x4129d858, skipping init
    07-31 08:59:35.816: I/System.out(572): calling the jni native method using findclass
    07-31 08:59:35.837: A/libc(572): Fatal signal 11 (SIGSEGV) at 0x1d2001ca (code=1)
    07-31 08:59:35.906: I/dalvikvm(572): threadid=3: reacting to signal 3
    07-31 08:59:35.945: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'
    07-31 08:59:36.426: I/dalvikvm(572): threadid=3: reacting to signal 3
    07-31 08:59:36.486: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'
    07-31 08:59:36.915: I/dalvikvm(572): threadid=3: reacting to signal 3
    07-31 08:59:36.965: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'
    07-31 08:59:37.416: I/dalvikvm(572): threadid=3: reacting to signal 3
    07-31 08:59:37.506: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'
    07-31 08:59:37.925: I/dalvikvm(572): threadid=3: reacting to signal 3
    07-31 08:59:37.975: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'
    07-31 08:59:38.406: I/dalvikvm(572): threadid=3: reacting to signal 3
    07-31 08:59:38.466: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'
    07-31 08:59:39.476: I/dalvikvm(572): threadid=3: reacting to signal 3
    07-31 08:59:39.516: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'


Please help me to solve this problem and run this application successfully. I will be very thankful for anykind of help. I am new to android so please help me.