• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JNI - UnsatisfiedLinkError

 
Ranch Hand
Posts: 64
4
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wasn't sure whether I should say this here or in the C/C++ forum, but here it is.

I'm programming a small game application for tutoring, where the GUI and main code are written in Java and the game logic implementation is written in some other language (in this case, C/C++) for the student to do. The implementation is mapped over via JNI and native methods.

I wrote a dummy implementation just to see if things would work. The native DLL library compiles fine, but Java does not seem to be able to link the method correctly.

The Java side:

The C++ side:

An UnsatisfiedLinkError is thrown upon reaching the line that calls initializeNativeStuff. Might I have named something wrong?
 
Sheriff
Posts: 22857
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you define PJNIEnv yourself? Because it's not part of the official JNI headers. And maybe that's the problem. Why don't you just let javah create the header file(s) for you? That would use JNIEnv * instead of PJNIEnv, but otherwise it would be the same.
 
Louis Denning
Ranch Hand
Posts: 64
4
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Changing PJNIEnv to JNIEnv* has no effect. They are the same type, as defined in a line I had forgotten to mention:


EDIT:

Problem solved. Issue was wrong compiler flags and missing extern "C" in the function prototypes in header.
 
reply
    Bookmark Topic Watch Topic
  • New Topic