Wednesday, August 8, 2007

The JNI UnsatisfiedLinkerError saga

Ever try to debug something where the solutions you found on the net does not seem to work in you machine ? Well I had one today.

Its actually related to the rather infamous UnsatisfiedLinkerError when running JNI related applications. My test code compiles OK & the DLL was built successfully. Nonetheless at runtime, said error always pops up.

I tried in vain at numerous compilation options as suggested on forums I found on the net but to no avail ... until I noticed this:




The UnsatisfiedLinkerError actually came from the line:


JNIEXPORT void JNICALL Java_ArrayHandler_returnArray


But since the ArrayHandler is actually in a package called org.semi, an UnsatisfiedLinkerError will arise at runtime. The correct signature would be as follows:


JNIEXPORT void JNICALL Java_org_semi_ArrayHandler_returnArray



Had a great laugh after I discovered this. There goes one day debugging something which should be obvious all along :)

The sample code I did can be downloaded at rapidshare, well, if they haven't deleted it yet :)