Comments on: JNI (Java Native Interface): Exception in thread “main” java.lang.UnsatisfiedLinkError: Can’t find dependent libraries Brief articles by Kai Witte Sun, 28 May 2017 08:52:01 +0000 hourly 1 By: 如何修复了UnsatisfiedLinkError错误(可以与# 39;找不到依赖库)在JNI项目 – CodingBlog Sun, 28 May 2017 08:52:01 +0000 […] fixed the method names in mylib.dll, as suggested here. The method names had somehow gotten mangled by the compiler, but I added linker flags and the dll […]

By: vivek Sun, 15 Jul 2012 18:33:11 +0000 -Wl, –kill-at OR -Wl,–add-stdcall-alias worked for me

Thank you SO much for your help kai W

By: Prahalad Das Tue, 12 Jun 2012 14:27:18 +0000 All thanks to you, i am able to run my first jni java after 11 years working in java & i used to give up in between and never used to work so hard to look for solution and used to stick with java alone.

Thanks to you solution
-Wl,–add-stdcall-alias -mno-cygwin

It did the all the magic, thanks for this kind blog.

By: Dhiral Sun, 10 Jun 2012 09:23:01 +0000 thanks a lot
i generate .dll files using GCC but it’s create problem like

But then i used TCC (Tiny C compiler ) and generate .dll and it’s works for me……..

By: javarevisited Sun, 11 Mar 2012 11:28:16 +0000 Nice tutorial and thanks for sharing information. I have also share my view as How to fix java.lang.unsatisfiedLinkError in java let me know how do you find it.

By: Jigar Thakkar Sun, 12 Feb 2012 07:50:26 +0000 Alexandra Niculai and degree are correct, deleting the -MD from the command works perfect thank you.

By: Hari Sun, 12 Feb 2012 05:01:34 +0000 Thanks Alexandra,
Yes, removing the -MD make it work for me! I am sure you know why by now. Could you pl. share it in this forum?

Regards … Hari

By: Mark M Fri, 27 May 2011 04:56:28 +0000 I have a probable solution for anyone getting this error when working with Eclipse! If you are loading your dll file as a resource into your system classloader, then you absolutely must do a project–>clean every single time you update your dll!! Even restarting eclipse or your computer won’t clear the old dll resource from your classloader. Tracking that one down was incredibly painful!

By: Daniel Mon, 16 May 2011 18:25:12 +0000 Idk if this will help anyone, but I’m using C++ compiling with VS win64 2010 command prompt.
I used the -MD option suggested fix and it did not affect my link problem.
I since my code was written in C++ I had modified my JNI header file code and removed this code:
“#ifdef __cplusplus
extern “C” {

//Method prototypes

#ifdef __cplusplus
Obviously I’m not very clever. Once I put this code back in and ran the dumpbin tool (thanks to whoever mentioned that first) I got a perfect looking signatures.
This solved my linking issue.

By: anandhrds Thu, 05 May 2011 08:07:12 +0000 Thanks for all the members in this post….
If you are using gcc complier, then add “-Wl,-kill-at” as one of the argument to gcc, This will solve the problem.
So, for example, in my case the command looks like this
“-Wl,-kill-at” -shared HelloWorld.c “-Ic:\Program Files\Java\jdk1.6.0_02\include” “-Ic:\Program Files\Java\jdk1.6.0_02\include\win32” -o ${workspace_loc:/JNISampleJava/bin}\HelloWorld.dll