I made a Dll file in visual studio 2010 and imported it to unity but unable to access functions-
the code goes like this-
the header file contains-
namespace MathFuncs
{
class MyMathFuncs
{
public:
// Returns a + b
static __declspec(dllexport) double Add(double a, double b);
};
}
the cpp file contains-#include “MathFuncsDll.h”
#include
using namespace std;
namespace MathFuncs
{
double MyMathFuncs::Add(double a, double b)
{
return a + b;
}
}
and the unity c# script goes this way-
using UnityEngine;
using System.Runtime.InteropServices;
class dllcheck : MonoBehaviour {
[DllImport(“MathFuncsDll”)]
private static extern double Add(double a, double b);
void Awake() {
Debug.Log(Add(5.0,7.0)); //shows runtime error pointing this line
}
}
and the error goes this way-
EntryPointNotFoundException: Add
dllcheck.Awake () (at Assets/Scenes/dllcheck.cs:17)
please help me out as i am stuck with my work.
Thanks in advance.