Hi,
I trying to use a c++ dll file in Unity. I´m just going crazy because it has worked in the past, but now it doesn´t. I followed the Unity Plugin example (http://docs.unity3d.com/Documentation/Manual/Plugins.html). The first which confuses me is that as far as I know you have to mark your method with “extern “C” __declspec(dllexport)” to use it use it in C#. And when it worked in my example only with this extension.
So I wrote a c++ dll file which contains the following code:
extern "C" __declspec(dllexport) void start(){
}
I placed the file into “…/Assets/Plugins” and tried to use it with this code in C#:
[DllImport("WASABIEngine")]
public static extern void start ();
When I now call this method I get an error message which says
“DllNotFoundException: G:/EmoAirport/Assets/Plugins/WASABIEngine.dll”.
This is the correct path where the dll file exists.
I was working a lot of time on this problem but I do not know what goes wrong. I am using Unity with a Pro/Educational License, so this feature should work.
I think the only different to the working version in the past is that I have switched from a MS C++ compiler to MinGW. I do knot know any more, which MS Compiler I was using, so I can not try to use this one again :-/. But I think this should be no problem.
I also think, that the error message is a little big ambiguous, and means, that the DLL file was found, but not the method. When I delete the DLL file from the directory, or set a wrong path in the DllImport directive I get an other slightly different message which says:
“DllNotFoundException: WASABIEngine”
This drives me crazy because it has worked, and I was working on it, to get a string as a return value, which is a little bit tricky.
Regards