如果VS2010不存在,为什么dll不运行?

时间:2011-07-18 14:59:42

标签: java visual-studio-2010 dll jna

我已经在VS2010上写了一个dll,我将在JNA的帮助下从JAVA调用它。但是如果计算机上不存在VS 2010则它不会运行。它会出错

  

线程“AWT-EventQueue-0”中的异常java.lang.UnsatisfiedLinkError:   无法加载库'C:\ Users \ hasan \ Desktop \ cv-2dll.dll':   找不到指定的模块。在   com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166)at at   com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239)at at   com.sun.jna.Library $ Handler。(Library.java:140)at   com.sun.jna.Native.loadLibrary(Native.java:393)at   com.sun.jna.Native.loadLibrary(Native.java:378)at   hsv.HSVHistogram.main(HSVHistogram.java:24)at   hsv.HSVView.jButton1ActionPerformed(HSVView.java:231)at at   hsv.HSVView.access $ 900(HSVView.java:25)at   hsv.HSVView $ 5.actionPerformed(HSVView.java:134)at   javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)     在   javax.swing.AbstractButton中的$ Handler.actionPerformed(AbstractButton.java:2318)     在   javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)     在   javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)     在   javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)     在java.awt.Component.processMouseEvent(Component.java:6288)at   javax.swing.JComponent.processMouseEvent(JComponent.java:3267)at   java.awt.Component.processEvent(Component.java:6053)at   java.awt.Container.processEvent(Container.java:2041)at   java.awt.Component.dispatchEventImpl(Component.java:4651)at   java.awt.Container.dispatchEventImpl(Container.java:2099)at   java.awt.Component.dispatchEvent(Component.java:4481)at   java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)     在   java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)     在java.awt.Container.dispatchEventImpl(Container.java:2085)at   java.awt.Window.dispatchEventImpl(Window.java:2478)at   java.awt.Component.dispatchEvent(Component.java:4481)at   java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)at at   java.awt.EventQueue.access $ 000(EventQueue.java:84)at   java.awt.EventQueue $ 1.run(EventQueue.java:602)at   java.awt.EventQueue $ 1.run(EventQueue.java:600)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.AccessControlContext $ 1.doIntersectionPrivilege(AccessControlContext.java:87)     在   java.security.AccessControlContext $ 1.doIntersectionPrivilege(AccessControlContext.java:98)     在java.awt.EventQueue $ 2.run(EventQueue.java:616)at   java.awt.EventQueue $ 2.run(EventQueue.java:614)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.AccessControlContext $ 1.doIntersectionPrivilege(AccessControlContext.java:87)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:613)at   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)     在java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

1 个答案:

答案 0 :(得分:0)

您的DLL可能需要C / C ++运行时DLL。没有安装Visual Studio 2010的计算机可能没有它们。

尝试编译DLL,以便将C / C ++运行时库静态链接到DLL中。在VS 2010中打开DLL项目的属性页面,然后选择Configuration Properties-> C / C ++ - > Code Generation子菜单并选择Multi-threaded(/ MT)或Multi-threaded Debug(/ MTd)。一旦你重新编译&重新链接它应该在没有VS 2010运行时DLL的系统上运行的DLL。