title: Unity - How to use c++ dll?
body: <p>I have an AR application. I created a c++ dll using visual studio 2013. I use this dll in my AR application like below : </p>
  
  <pre><code>**In private members region :**
  [DllImport ("DllExample")]
  private static extern int func(int x, int y);
  .......
  
  **In a C# function :** 
  if (func((int)pos.x, (int)pos.y) == -1) {
      ...
  }
  else {              
      ...
  }
  </code></pre>
  
  <p>My unity application works fine unity editor. I build this app for android. When I run it on a android device, it doesn't work.</p>
  
  <p>Content of C++ dll :</p>
  
  <pre><code>// dllmain.cpp : Defines the entry point for the DLL application.
  #include "stdafx.h"
  #include &lt;opencv2\core\core.hpp&gt;
  #include &lt;opencv2\highgui\highgui.hpp&gt;
  #include &lt;opencv2\imgproc\imgproc.hpp&gt;        
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  
  extern "C" __declspec(dllexport) int func(int x, int y);
  
  BOOL APIENTRY DllMain( HMODULE hModule,
                     DWORD  ul_reason_for_call,
                     LPVOID lpReserved
                   )
  {
  switch (ul_reason_for_call)
  {
  case DLL_PROCESS_ATTACH:
  case DLL_THREAD_ATTACH:
  case DLL_THREAD_DETACH:
  case DLL_PROCESS_DETACH:
      break;
  }
  return TRUE;
  }
  
  
  __declspec(dllexport) int func(int x, int y)
  {   
  cv::RNG rng(12345);
  cv::Mat image0, image, gray, mask;
  int ffillMode = 1;
  int loDiff = 20, upDiff = 20;
  int connectivity = 4;
  int isColor = true;
  bool useMask = false;
  int newMaskVal = 255;
  
  return x;
  }
  </code></pre>
  
  <p>In unity C# file, if I remove call dll function, the application works fine on my android device .I use free unity version. How can I use a c++ dll on a mobile device?</p>