我只是在学习如何使用 Java JNA,我正在尝试从 Microsoft Kinect SDK 调用一个简单的函数。(NuiGetSensorCount) 它只返回连接的 kinect 的数量。
这是我的尝试:
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
public class Driver {
public interface KinectLibrary extends Library {
KinectLibrary INSTANCE = (KinectLibrary)Native.loadLibrary(("Microsoft.Kinect"),KinectLibrary.class);
//_Check_return_ HRESULT NUIAPI NuiGetSensorCount( _In_ int * pCount );
NativeLong NuiGetSensorCount(Pointer pCount);
}
public static void main(String[] args) {
Pointer devCount = new Pointer(0);
KinectLibrary.INSTANCE.NuiGetSensorCount(devCount);
System.out.println("Devices:"+devCount.getInt(0));
}
}
但我得到:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'NuiGetSensorCount': The specified procedure could not be found.
at com.sun.jna.Function.<init>(Function.java:208)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
at com.sun.jna.Library$Handler.invoke(Library.java:199)
at $Proxy0.NuiGetSensorCount(Unknown Source)
at Driver.main(Driver.java:30)
任何人都可以提供有关如何更改我的代码以找到正确的本机功能的帮助吗?并且还提供一些信息/参考,以便我可以尝试自己调试(以某种方式查看 Java JNA 正在寻找什么功能,并将其与 .dll 包含的内容进行比较)