java-native-interface

ldd outputs statically linked on a shared library

╄→尐↘猪︶ㄣ 提交于 2021-01-27 17:04:10
问题 I am trying to create a shared library libddv3djava.so I compile sources for libddv3djava.so like so: ~/Programming/intellijprojects/ddv3dbindingstest/src $ g++ -c -Wall -Werror -I. -I /usr/lib/jvm/java-8-oracle/include/ -I /usr/lib/jvm/java-8-oracle/include/linux/ -fpic com_ddv3d_Ddv3dBinding.cpp Creating libddv3djava.so: ~/Programming/intellijprojects/ddv3dbindingstest/src $ g++ -shared -o libddv3djava.so com_ddv3d_Ddv3dBinding.o When I do ldd on libddv3djava.so: ~/Programming

Why do I get UnsatisfiedLinkError when calling a MinGW-compiled function (not loading the library) on Windows?

♀尐吖头ヾ 提交于 2021-01-27 09:04:04
问题 I'm making a simple JNI test app using Eclipse on Windows. My C++ compiler is MinGW 4.6.2. Java is throwing an UnsatisfiedLinkError when I try to invoke a function in my test DLL (the DLL itself loads without problem). I have verified that my DLL exports a "C" function with the same name as the function generated by the javah utility. How could trying to invoke the function possibly generate a link error? (Also, is there any way to get more detail as to what symbol isn't being found? A bald

Why do I get UnsatisfiedLinkError when calling a MinGW-compiled function (not loading the library) on Windows?

余生长醉 提交于 2021-01-27 09:03:41
问题 I'm making a simple JNI test app using Eclipse on Windows. My C++ compiler is MinGW 4.6.2. Java is throwing an UnsatisfiedLinkError when I try to invoke a function in my test DLL (the DLL itself loads without problem). I have verified that my DLL exports a "C" function with the same name as the function generated by the javah utility. How could trying to invoke the function possibly generate a link error? (Also, is there any way to get more detail as to what symbol isn't being found? A bald

Why do I get UnsatisfiedLinkError when calling a MinGW-compiled function (not loading the library) on Windows?

我只是一个虾纸丫 提交于 2021-01-27 09:01:07
问题 I'm making a simple JNI test app using Eclipse on Windows. My C++ compiler is MinGW 4.6.2. Java is throwing an UnsatisfiedLinkError when I try to invoke a function in my test DLL (the DLL itself loads without problem). I have verified that my DLL exports a "C" function with the same name as the function generated by the javah utility. How could trying to invoke the function possibly generate a link error? (Also, is there any way to get more detail as to what symbol isn't being found? A bald

JNI GetByteArrayElements () Error

雨燕双飞 提交于 2021-01-27 07:56:28
问题 I'm new in JNI so I'm not familiar in JNI and also English. My JNI project is a simple File reading and writing. File reading in Java and passing the byte array to C API the write it into file using C. My source code: Java code is : public class FileIO { static { System.loadLibrary("FileIO"); } private native void writeFile(byte[] msg); public static void main(String[] args) throws IOException { byte[] array = Files.readAllBytes(new File("PtFBWCTn.mp3").toPath()); // System.out.println(array

JNI GetByteArrayElements () Error

空扰寡人 提交于 2021-01-27 07:53:51
问题 I'm new in JNI so I'm not familiar in JNI and also English. My JNI project is a simple File reading and writing. File reading in Java and passing the byte array to C API the write it into file using C. My source code: Java code is : public class FileIO { static { System.loadLibrary("FileIO"); } private native void writeFile(byte[] msg); public static void main(String[] args) throws IOException { byte[] array = Files.readAllBytes(new File("PtFBWCTn.mp3").toPath()); // System.out.println(array

How to convert char* to jcharArray in JNI

 ̄綄美尐妖づ 提交于 2021-01-27 06:53:00
问题 How can I convert char* to jcharArray in JNI? What code do I have to put in // TODO comment part? JNIEXPORT jcharArray JNICALL Java_finger_FingerPrintJNI_GetVer(JNIEnv *env, jobject thisObj){ char* version = getText(); // Returns char* data type int version_len = strlen(version); jcharArray j_version_array = env->NewCharArray(version_len + 1); // TODO Convert char* to jcharArray return jcharArray; } Add ====================================================================== As Gearon suggested

How to convert char* to jcharArray in JNI

强颜欢笑 提交于 2021-01-27 06:51:54
问题 How can I convert char* to jcharArray in JNI? What code do I have to put in // TODO comment part? JNIEXPORT jcharArray JNICALL Java_finger_FingerPrintJNI_GetVer(JNIEnv *env, jobject thisObj){ char* version = getText(); // Returns char* data type int version_len = strlen(version); jcharArray j_version_array = env->NewCharArray(version_len + 1); // TODO Convert char* to jcharArray return jcharArray; } Add ====================================================================== As Gearon suggested

JNI Object Pointers

别来无恙 提交于 2021-01-27 04:18:09
问题 Problem When experimenting with the JNI interface, I was wondering if I could take a JObject and transmute it into an equivalent struct to manipulate the fields. However, when I tried I was surprised to see that this did not work. Ignoring how horrible this idea might be, why didn't it work? My Approach Java Test Class I made a simple class Point to do my test. Point has two fields and a constructor that takes in an x and y as well as a few random methods that return information based on the

How to include a binary file with Android NDK project?

断了今生、忘了曾经 提交于 2021-01-24 08:49:41
问题 I know its bad practice but whats the best way to include a binary file with Android NDK project? The file should be executable with the system command. I don't want to copy it manually copy to the device but distribute it within my .apk. 回答1: It is enough to rename the executable to "lib_myexecutable_.so" and put it in libs/armeabi folder under your project root: this file will be extracted by the Package Manager on the device to /data/data/your.package.full.name/lib , with executable