Mail Archives: cygwin/1998/10/22/03:49:07
Hi,
I thought others might be interested in this letter I sent to Mumit:
-----
I tried using your dllwrap tool and method to create the JNI HelloWorld
example and it failed as it couldn't find the native routine in the library,
whereas Andrew Mickish's method:
http://www.andrew.cmu.edu/~am2q/HelloWorld.zip
worked fine for the HelloWorld code. Looking at the code I can't see any
glaring differences. His makefile uses the loader/dlltool/loader/dlltool
method. I tried using Andrew's example on a larger piece of code and it
behaves the same as yours, i.e. the library loads but it can't find the
routines within the library. Perhaps his can only load one routine? ;-)
Any hints?
My environment is:
Windows/NT on a dual processor pentium.
gcc -v = egcs-2.91.57 19980901 (egcs-1.1 release) (cygwin - B19)
binutils (2.7-B19)
dllhelpers-0.2.1
I had to set DLL_LDFLAGS = -Wl,-e,_dll_entry AT 12 to avoid errors.
Your dllwrap method failed with:
============================Makefile================================
..SUFFIXES: .java
..SUFFIXES: .class
DLL_OBJS = HelloWorldImp.o
DLL_NAME = hello.dll
DLL_EXP_DEF = hello.def
DLL_EXP_LIB = libhello.a
DLLWRAP = dllwrap
DLLTOOL = dlltool
JAVA_HOME=/jdk1.1.6
# Java Files
JSRCS = HelloWorld.java Main.java
JLIBBIN = HelloWorldImp.o
JOBS=$(JSRCS:.java=.class)
DLLWRAP_FLAGS = --driver-name $(CC) --def $(DLL_EXP_DEF)
DLL_CFLAGS = -DBUILDING_DLL=1
# The default entry point defined by dllwrap is DllMain defined in
# dllinit.c. You can override that here by specifying it in DLL_LDFLAGS.
# (eg., -Wl,-e,_MyDllMain AT 12 -- note the leading underscore and the
# trailing @12).
DLL_LDFLAGS = -Wl,-e,_dll_entry AT 12
all: $(DLL_NAME) $(JOBS) $(JLIBBIN)
$(DLL_NAME): $(DLL_OBJS) $(DLL_EXP_DEF)
$(DLLWRAP) $(DLLWRAP_FLAGS) -o $(DLL_NAME) \
$(DLL_OBJS) $(DLL_LDFLAGS) $(DLL_LDLIBS)
$(DLL_EXP_LIB): $(DLL_EXP_DEF)
$(DLLTOOL) --dllname $(DLL_NAME) --def $(DLL_EXP_DEF) \
--oubput-lib $(DLL_EXP_LIB)
$(DLL_EXP_DEF): $(DLL_OBJS)
$(DLLTOOL) --export-all --output-def $@ $(DLL_OBJS)
HelloWorldImp.o: HelloWorldImp.c HelloWorld.h
gcc -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 -c HelloWorldImp.c
..java.class:
$(JAVA_HOME)/bin/javac $*.java
HelloWorld.h: HelloWorld.class
$(JAVA_HOME)/bin/javah HelloWorld
clean:
rm -f *.class *.o core hello.dll*
==============================HelloWorld.java============================
class HelloWorld {
public native void displayHelloWorld();
static {
System.loadLibrary("hello");
}
}
==============================HelloWorldImp.c============================
/* following for PC port */
#define __int64 long
#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world!\n");
return;
}
==============================Output=====================================
/jdk1.1.6/bin/javac HelloWorld.java
/jdk1.1.6/bin/javah HelloWorld
gcc -I/jdk1.1.6/include -I/jdk1.1.6/include/win32 -c HelloWorldImp.c
dlltool --export-all --output-def hello.def HelloWorldImp.o
dllwrap --driver-name gcc --def hello.def -o hello.dll \
HelloWorldImp.o -Wl,-e,_dll_entry AT 12
/jdk1.1.6/bin/javac Main.java
/jdk1.1.6/bin/java Main
java.lang.UnsatisfiedLinkError: displayHelloWorld
at Main.main(Main.java:3)
=========================================================================
Am I missing something here? (besides my sanity! ;-)
Thanks,
Glen
--
Glen Fullmer,(847)538-3082, Mail: <gfullmer AT ccrl DOT mot DOT com>,
*******************************************************************************
* "For a successful technology, reality must take precedence *
* over public relations, for Nature cannot be fooled." - Richard P. Feynman *
*******************************************************************************
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -