I’ve been trying to write simple functions in C and use IL2CPP to include them in my plugin directory directly without building DLLs because I find it more straightforward as well as less costly P/Invoke wise as well as maybe not needing to restart Unity each time I make a change.
But when I target IL2CPP scripting back-end w/ standalone target I always get this error in the editor in play mode: EntryPointNotFoundException And when I build I get /il2cpp.exe did not run properly!
I have VS2019 w/ C++ workload and Windows 10 SDK.
Anyone knows how to use native source files and IL2CPP in Unity?
Sample code:
#include <math.h>
#define EXPORT __declspec(dllexport)
/* Power function*/
EXPORT int power1(int n, int p)
{
int r = pow(n, p);
return r;
}
C#
[DllImport("__Internal", EntryPoint ="power1")] static extern int power1(int n, int p);