Forgive if this issue has been addressed in the past. I didn't see it in
a quick look through the archives.
I'm interested in using JNA within JRuby for two purposes:
- to call native libraries for functions that do not yet exist in the
Java libraries (chown, fcntl, etc)
- to provide a mechanism for loading C Ruby extensions
There's also a few native library implementations in the Ruby standard
library I'd like to implement (DL, for general purpose dylib access;
win32api for win32; gtk; tk; and on and on)
So I'm trying to get it up and working. The CLibrary example worked ok,
but when I made my own (empty) interface and tried to
Native.loadLibrary("libc.dylib", LibC.class) I got this:
irb(main):004:0> libc = Native.loadLibrary("libc.dylib",
java.lang.Class.forName("LibC"))
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot locate
function 'toString'
at
com.sun.jna.NativeLibrary.getFunctionAddress(NativeLibrary.java:197)
at com.sun.jna.Function.<init>(Function.java:106)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:184)
at com.sun.jna.Library$Handler.invoke(Library.java:142)
at $Proxy4.toString(Unknown Source)
at org.jruby.javasupport.JavaObject.to_s(JavaObject.java:132)
Pointers?
- Charlie