Mail Archives: cygwin/2002/12/15/16:07:43
Hi,
Calling a DLL under Cygwin from IBM Java13 via JNI fails if the DLL depends
on cygwin1.dll. I am using the following versions:
uname -a
CYGWIN_NT-5.1 CALVIN 1.3.17(0.67/3/2) 2002-11-27 18:54 i686 unknown
gcc-2 --version
2.95.3-10
java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Classic VM (build 1.3.0, J2RE 1.3.0 IBM build cn130-20020124 (JIT enabled:
jitc)
)
You can reproduce this with HelloWorld.java:
<<<
class HelloWorld {
public native void displayHelloWorld();
static {
System.loadLibrary("HelloWorld");
}
public static void main(String[] args) {
new HelloWorld().displayHelloWorld();
}
}
>>>EOF HelloWorld.java
HelloWorld.c: <<<
#include <windows.h>
#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env,
jobject obj)
{
printf("Hello world!\n");
return;
}
>>> EOF HelloWorld.c
HelloWorld.c I compiled with
gcc-2 -shared -I/cygdrive/c/Programme/IBM/Java13/include -Wl,--add-stdcall-a
lias -o HelloWorld.dll HelloWorld.c
"java -verbose -classpath . HelloWorld" crashes with the following output:
[Running static initializer for HelloWorld]
[Signaling in VM: java/lang/UnsatisfiedLinkError, message:
C:\Programme\IBM\Java
13\jre\bin\HelloWorld.dll: Can't find dependent libraries]
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1470)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1346)
at java.lang.Runtime.loadLibrary0(Runtime.java:766)
at java.lang.System.loadLibrary(System.java:849)
at HelloWorld.<clinit>(HelloWorld.java:15)
[Loaded java.lang.UnsatisfiedLinkError from
C:\Programme\IBM\Java13\jre\lib\rt.j
ar]
[Loading superclasses of java/lang/UnsatisfiedLinkError]
[Preparing java/lang/UnsatisfiedLinkError]
[Loaded java.lang.ClassLoader$4 from C:\Programme\IBM\Java13\jre\lib\rt.jar]
[Loading superclasses of java/lang/ClassLoader$4]
[Preparing java/lang/ClassLoader$4]
[Signaling in VM: java/lang/UnsatisfiedLinkError, message:
C:\Programme\IBM\Java
13\bin\HelloWorld.dll: Can't find dependent libraries]
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1470)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1358)
at java.lang.Runtime.loadLibrary0(Runtime.java:766)
at java.lang.System.loadLibrary(System.java:849)
at HelloWorld.<clinit>(HelloWorld.java:15)
Please note there are no JVM shutdown messages. Cygwin1.dll is in %PATH%.
HelloWorld.dll can be loaded fine from other clients such as a MS Visual C++
with MFC.
If I add -mno-cygwin when compiling, HelloWorld.dll is loaded and invoked
just fine. But I need the cygwin1.dll for my project.
What can I do?
Frank
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -