title: Writing C++ .dlls and access them Unity-3D
body: <p>I have been writing a basic dll in c++ with the end-goal of accessing some of it's methods in Unity. I started this tutorial in : <a href="http://docs.unity3d.com/Documentation/Manual/Plugins.html" rel="nofollow">http://docs.unity3d.com/Documentation/Manual/Plugins.html</a> which helped me understand the concept but after I write the class in Unity and access the .dll it throws me an entry point exception error when I hit play. And yes, I have a plugin folder where i keep my .dll file. </p>
  
  <blockquote>
    <p>EntryPointNotFoundException: addition PluginImport.Start () (at
    Assets/Test/PluginImport.cs:20)</p>
  </blockquote>
  
  <p>Here is my .dll class. </p>
  
  <p>The Header File:</p>
  
  <pre><code>#ifndef MATHASSISTANT_ARITHMETICS_ARITHMETIC_H
  #define MATHASSISTANT_ARITHMETICS_ARITHMETIC_H
  
  namespace ma{
      extern "C"
      {
      class Arithmetic
      {
      public:
          Arithmetic();//ctor
      protected:
          virtual ~Arithmetic();//dtor
      public:
  
          static __declspec(dllexport) float addition(float&amp; val_1, float&amp; val_2);
          static __declspec(dllexport) float substraction(float&amp; val_1, float&amp; val_2);
          static __declspec(dllexport) float multiplication(float&amp; val_1, float&amp; val_2);
          static __declspec(dllexport) float division(float&amp; val_1, float&amp; val_2);
      };
      }
  }
  
  #endif
  </code></pre>
  
  <p>This is the source file:</p>
  
  <pre><code>#include "Arithmetic.h"
  #include &lt;stdexcept&gt;
  
  namespace ma{
  
  
      Arithmetic::Arithmetic(){
          //TODO: Initialize items here
      }
      Arithmetic::~Arithmetic(){
          //TODO: Release unused items here
      }
  
      //FUNCTION: adds two values
      float Arithmetic::addition(float&amp; val_1, float&amp; val_2){
          return val_1 + val_2;
      }
      //FUNCTION: substracts two values
      float Arithmetic::substraction(float&amp; val_1, float&amp; val_2){
          return val_1 - val_2;
      }
      //FUNCTION: multiplies two values
      float Arithmetic::multiplication(float&amp; val_1, float&amp; val_2){
          return val_1 * val_2;
      }
      //FUNCTION: divide two values
      float Arithmetic::division(float&amp; val_1, float&amp; val_2){
          if(val_2 == 0)
              throw new std::invalid_argument("denominator cannot be 0");
          return val_1 / val_2;
      }
  }
  </code></pre>
  
  <p>This is the class I created in Unity3D:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System;
  using System.Runtime.InteropServices;
  
  public class PluginImport : MonoBehaviour
  {
      //Lets make our calls from the Plugin
      [DllImport("Arithmetic")]
      private static extern float addition(float val_1, float val_2);
      [DllImport("Arithmetic")]
      private static extern float substraction(float val_1, float val_2);
      [DllImport("Arithmetic")]
      private static extern float multiplication(float val_1, float val_2);
      [DllImport("Arithmetic")]
      private static extern float division(float val_1, float val_2);
  
      void Start()
      {
          Debug.Log(addition(5, 5));
          Debug.Log(substraction(10, 5));
          Debug.Log(multiplication(2, 5));
          Debug.Log(division(10, 2));
      }
  }
  </code></pre>
  
  <p>If anyone can help me find what I am doing wrong I will be most appreciative. Thanks in advance!</p>