My C++ code is below.
#include "stdafx.h"
#include "testDll.h"
TESTDLL_API int ntestDll=0;
TESTDLL_API int _fntestDll(void)
{
return 42;
}
CtestDll::CtestDll()
{
return;
}
It a simple code made by example.
And my C# code in Unity is below.
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
[DllImport("testDll")]
private static extern int _fntestDll();
void Start () {
Debug.Log(_fntestDll());
}
// Update is called once per frame
void Update () {
}
}
It very simple too. I just want to check how to use it. But it always show the following message.
EntryPointNotFoundException: _fntestDll
NewBehaviourScript.Start () (at Assets/NewBehaviourScript.cs:11)
I have no idea why it happen. I have use pro in Unity. But still not work.