JNI Hello World Unsatisfied Link Error

后端 未结 5 1211
抹茶落季
抹茶落季 2020-11-30 13:58

This is my first attempt at JNI. My ultimate goal is to get all tasks currently running on a machine, but need to get even a simple example running. I keep getting this erro

5条回答
  •  再見小時候
    2020-11-30 14:24

    If you change the location (package) of your native function declaration from the java side without updating the h file, and the signature of the method in the c++ side, It won't resolve to the method and will throw unsatisfied..

    package x;
    public class A {
        private native void print();
        ...
    }
    

    moved to:

    package x.y;
    public class A {
        private native void print();
        ...
    }
    

    This will require regeneration of the H file (to something like Java_x_y_A_print ).

    Note you can change those signatures manually but I won't recommend

提交回复
热议问题