More Java JNI with GNU-WIN32 gcc

Andrew Mickish mickish@cmu.edu
Tue Jun 30 14:51:00 GMT 1998


Here are a few more issues that came up when trying to compile a JNI DLL with
gcc.

*  There are two different problems that could cause Unsatisfied link errors.
One is
if the DLL is not found, and the other is if the DLL is found but is
unreadable or
the specific function cannot be found in it.  These problems are
distinguishable by
the stack trace that you get below the "Unsatisfied link error," and also by
testing
for changes in behavior when you run Java after deliberately deleting the DLL
or
deliberately renaming some arbitrary text file to be your DLL.

*  The directory containing the DLL ought to be in your PATH.  The recommended
way to
set your path is to change it with the System control panel and open a new
window.
The cygnus.bat file munges the path a little itself, so my own path ends up
looking
like this:

    bash-2.01$ echo $PATH
    /Cygnus/B19/H-i386-cygwin32/bin:/WINNT/system32:/WINNT:/utils:/enscript:
    //E/jdk1.1.5/bin://E/java/HelloWorld

*  I had to hand-edit the DEF file and put in an alias for the exported
function.  Without the alias, it seems that Cygnus is exporting the mangled
name of the function with its offset ("...@8") and Java is looking for an
unmangled name.  My DEF file looks like this:

    bash-2.01$ cat hello.def
    EXPORTS
    Java_HelloWorld_displayHelloWorld=Java_HelloWorld_displayHelloWorld@8
    dll_entry@12


Please let me know if any of this has been helpful.

--Andrew Mickish
  mickish@cmu.edu





More information about the Cygwin mailing list