title: JNI use .hpp library inside C++
body: <p>I am trying to use JNI with C++. I'm able to create a Hello-World JNI project following <a href="https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html" rel="nofollow noreferrer">this</a> tutorial. </p>
  
  <p>But, I want to use <a href="https://github.com/nlohmann/json" rel="nofollow noreferrer">JSON for modern C++</a> inside my C++ function. This library contains only a <code>json.hpp</code> file that I include inside my project.
  Everything compile well, I got my <code>hello.dll</code> file but when I run my Java application, I got this error : </p>
  
  <pre><code>$ java HelloJNI java.lang.UnsatisfiedLinkError: C:\Users\Levio-CIL\Desktop\TEST\hello.dll: Can't find dependent libraries
          at java.lang.ClassLoader$NativeLibrary.load(Native Method)
          at java.lang.ClassLoader.loadLibrary0(Unknown Source)
          at java.lang.ClassLoader.loadLibrary(Unknown Source)
          at java.lang.Runtime.loadLibrary0(Unknown Source)
          at java.lang.System.loadLibrary(Unknown Source)
          at HelloJNI.&lt;clinit&gt;(HelloJNI.java:3) Exception in thread "main"
  </code></pre>
  
  <p>I did some tests, and it seems that the .dll can't find the function inside <code>json.hpp</code>. When I remove this function, everything works well. The C++ program can also run successfully as a standalone.</p>
  
  <p><strong>HelloJNI.java:</strong></p>
  
  <pre><code>public class HelloJNI {
     static {
        System.loadLibrary("hello"); 
     }
  
     private native void sayHello();
  
     public static void main(String[] args) {
        new HelloJNI().sayHello();  // invoke the native method
     }
  }
  </code></pre>
  
  <p><strong>HelloJNI.cpp:</strong> </p>
  
  <pre><code>#include &lt;jni.h&gt;
  #include "HelloJNI.h"
  #include "json.hpp"
  
  using json = nlohmann::json;
  
  // Implementation of native method sayHello() of HelloJNI class
  JNIEXPORT void JNICALL Java_HelloJNI_sayHello(JNIEnv *env, jobject thisObj) {
  
      json specific_data = json::parse("{\"id\": \"aa\",\"value\": 1,\"type\": \"water\"}"); //THE PROBLEMATIC LINE
      printf("Hello world");
      return;
  }
  </code></pre>
  
  <p><strong>Additional Information :</strong> </p>
  
  <p>I'm Using Windows 10 with cygwin64. </p>
  
  <p>I compile my c++ file with this command :  </p>
  
  <pre><code>x86_64-w64-mingw32-g++ -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" -shared -o hello.dll HelloJNI.cpp json.hpp
  </code></pre>
  
  <p>Every file is inside the same directory.</p>
  
  <p><strong>EDIT :</strong>
  I included missing library provided by Dependency Walker but still got the same error. (And Yes, I run with the .dll inside my workdir)</p>