昨天在调试一个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:
- 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".
- 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.
阅读(761) | 评论(0) | 转发(0) |