title: JNI:how to call c++ function from Java Native Method
body: <p>i am working on some java application in which i am using jni. Well here now i want to call <strong>pure c++ function from JNI method</strong>. well i am doing this as shown as below code. here dll is created but when i am trying run i get the error  <strong>java.lang.UnsatisfiedLinkError:  Can't find dependent libraries</strong>. i am creating my dll in visual studio. so tell me what i am doing wrong in calling c++ function.</p>
  
  <p>here is code of my .cpp file</p>
  
  <pre><code>#include "SensorDetect.h"
  #include &lt;stdio.h&gt;
  #include &lt;windows.h&gt;
  // Include specific Tools header
  #include "Tools.h"
     // Include IO_XRayUSB_MD_VC80 header
  #include "IO_XRayUSB.h"
  
  // Include IO_XRayUSB_MD_VC80 library
  #pragma message ("Using : IO_XRayUSB_MD_VC80.lib")
  #pragma comment(lib, "IO_XRayUSB_MD_VC80.lib")
  
  //// Custom user Callback function which is called by IO_XrayUsb when a device is plugged or unplugged
  void _stdcall DevicePlugUnplugCallback(XRay_CALLBACK * pCallBackInfo, int nCallBackCount)
  {
      if (pCallBackInfo &amp;&amp; (nCallBackCount &gt; 0))
      {
          for (int nDeviceIndex = 0; nDeviceIndex &lt; nCallBackCount; nDeviceIndex ++)
          {
              switch(pCallBackInfo[nDeviceIndex].nState)
              {
                  case XRAY_USB_PLUGGED_DEVICE :
                      printf("\n=&gt;Callback Device: %s has been Plugged...\n\n", pCallBackInfo[nDeviceIndex].pcDeviceName);
                      break;
                  case XRAY_USB_UNPLUGGED_DEVICE :
                      printf("\n=&gt;Callback Device: %s has been Unplugged...\n\n", pCallBackInfo[nDeviceIndex].pcDeviceName);
                      break;
                  default:
                      break;
              }
          }
      }
  }
  
  
  extern "C"
  JNIEXPORT void JNICALL Java_sensordetect_SensorDetect_getDevice(JNIEnv * env, jclass cl)
  {
  
       const int nNbMaxDevices = 10;
      char pDeviceList[nNbMaxDevices][260];
      int nDeviceCount = 10;
      XRay_HANDLE hDevice;
      XRay_SENSOR_INFO SensorInfo;
  
  
      //int nTriggerMode = GetChoice(1, "Choose Trigger Mode:\t0:XVIS_detection    1:TWI_request_detection");
      char pcBuffer[100];
      int nKey;
  
          nKey=0;
  
              int nTriggerMode=nKey;
  
      try
      {
          // XRay_RegisterCallBackPlugDevice to be notified of device plug/unplug
  **//This function call creates problem in loading dll. error:Can't find dependent libraries**
       BOOL bSuccess = XRay_RegisterCallBackPlugDevice(DevicePlugUnplugCallback);    
  
  
          //for (int nIndex = 0; nIndex &lt; 1; nIndex ++)
              printf("\tFound device : %s\n", pDeviceList[0]);
  
      }
      catch (...) // catch own CMyException
          {
              //e.ShowReason();
          }
  
      }
  </code></pre>