I am trying to write a custom linux library(*.so) and I stuck already at the basics. I would like to use this library via JNA. The problem is that when Eclipse is trying to run the method Test()
this error-message appears Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'Test': /path/to/libexports.so undefined symbol: Test
Here is the lib code:
#ifdef EXPORTS
#define NATIVE_API __declspec(dllexport)
#else
#define NATIVE_API __declspec(dllimport)
#endif
extern "C" {
NATIVE_API int __stdcall Test(){
cout << "hello!";
}
}
This is the Java code:
public interface IJnaTest extends StdCallLibrary{
IJnaTest instance = (IJnaTest) Native.loadLibrary("exports", IJnaTest.class);
public int Test();
}
The call in the main:
IJnaTest.instance.Test()
Can anybody tell me why this is not working?
Regards Wurmi
Ahh. I found it!
I had to extend the interface just from Library not from StdCallLibrary.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.