• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JNI example gives UnsatisfiedLinkError

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have copied and compiled the JNI example given by Sun at http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/index.html. I used gcc on cygwin to compile HelloWorldImp.c. When I run it, I get the following error:



The the current directory is in PATH, so it's not a path issue. The JNIEXPORT appears to be properly defined in jni.h, so it shouldn't be an issue of exporting the function. Any other suggestions?

I'm running a completely updated cygwin on win2k. HelloWorldImp.c is:

 
slade cox
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel stupid posting a question and then replying with the solution. But, I found the problem so I might as well post it. Two switches needed to be added to the gcc command.

-Wl,--add-stdcall-alias
This seems to export the function correctly, while the JNIEXPORT seems to do nothing at all. (-Wl,--kill-at seems to work as well. Anyone know what difference it makes beyond a smaller file?)

-mno-cygwin
Without this, java exits abruptly with exit code 128 and no error messages. I presume this is a bug/issue with cygwin.
 
A feeble attempt to tell you about our stuff that makes us money
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic