I'm trying to use some external C++ code in my C# (Unity) project. I decided to create a .dll file. My problem is when I try to run my program, it throws an exception at calling dll's function. My code looks something like this:
// Something.h
#ifndef SOMETHING_H
#define SOMETHING_H
extern "C" __declspec(dllexport) int __stdcall f(int a, const char** b, char* c);
#endif
// Something.cpp
int f(int a, const char** b, const char* c) {
// some stuff
}
// Something.cs
using System.Runtime.InteropServices;
public class Something
{
[DllImport("Something.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int f(
int a,
[In][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] string[] b,
[In][MarshalAs(UnmanagedType.LPStr)] string c
);
}
I'm think that I'm doing something nasty with that string[] -> const char**
conversion but i'm not sure because it's my first try with mixing languages by .dll or .so.
Here is the part of exception thrown:
System.EntryPointNotFoundException: f
at (wrapper managed-to-native) Something.f(int,string[],string)
Thanks for any attention.
Best Regards,
Xavrax