• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic