• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNI - UnsatisfiedLinkError  RSS feed

 
Ranch Hand
Posts: 64
4
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!