我在用 jna 加载 dll 时遇到问题。虽然我可以在 eclipse 中调试代码,但当我将它导出并作为 jar 文件运行时,我得到一个异常:
java.lang.UnsatisfiedLinkError:无法加载库“SiUSBXp”
当我将它作为 jar 文件运行时,为什么它找不到我的 dll 有什么想法吗?
谢谢!!!!
public interface SiUSBXp extends StdCallLibrary {
byte SI_GetNumDevices(IntByReference numdevices);
byte SI_GetProductString( int deviceNum, byte[] productString, int options );
byte SI_Open(IntByReference numdevices);
}
static SiUSBXp INSTANCE;
public static void main(String[] args) {
System.setProperty("jna.library.path","SiUSBXp.dll");
HashMap<String, StdCallFunctionMapper> optionMap = new HashMap<String, StdCallFunctionMapper>();
StdCallFunctionMapper myMapper = new StdCallFunctionMapper();
optionMap.put(Library.OPTION_FUNCTION_MAPPER, myMapper);
INSTANCE = (SiUSBXp) Native.loadLibrary("SiUSBXp", SiUSBXp.class, optionMap);
}
Run Code Online (Sandbox Code Playgroud)
- - - - - - - - - 编辑 - …