Chinaunix首页 | 论坛 | 博客
  • 博客访问: 53697
  • 博文数量: 20
  • 博客积分: 1240
  • 博客等级: 中尉
  • 技术积分: 270
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-02 09:47
文章存档

2010年(1)

2009年(5)

2008年(14)

我的朋友
最近访客

分类: WINDOWS

2008-10-04 21:19:06

昨天在调试一个Dll,我使用minGW编译器编译通过,放于windows的system32目录下,使用java做了一个本地jni调用,结果死活通不过,报错如下:
Exception in thread "main" java.lang.UnsatisfiedLinkError: jni_t1.msgBox(Ljava/lang/String;)V
 at jni_t1.msgBox(Native Method)
 at jni_t1.main(jni_t1.java:15)
怎么回事呢?连接错误?可是我dll明明放对了位置啊,未果。
 
后来终于查到了一条,也有人出现过这个错误,也是使用的这个编译器。由于手头没有vc,于是第二天起电脑城买了一张vs2005,编译后,果然ok,不知道是什么原因。vs编译后的dll再调用其他编译器编译的dll,都没有发现有问题。不知道sun的jni为什么必须用vc编译才行;
 
第二个,code::block编译后的工程,使用vs2005打开后也出错,报错为:error:cannot convert parameter  from 'const char[12]'to'LPCWSTR' 的错误信息。弄了半天,才找到是哪里出的毛病。
下面是关于解决这个错误的一些资料:

Resolution

You will have to do one of two things:

  1. Change your project configuration to use multibyte strings. Press ALT+F7 to open the properties, and navigate to Configuration Properties > General. Switch Character Set to "Use Multi-Byte Character Set".
  2. Indicate that the string literal, in this case "Hello world!" is of a specific encoding. This can be done through either prefixing it with L, such as L"Hello world!", or surrounding it with the generic _T("Hello world!") macro. The latter will expand to the L prefix if you are compiling for unicode (see #1), and nothing (indicating multi-byte) otherwise.

阅读(583) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~