I'm using a Dll created from a C++ file. When I either put the .dll and .lib files in my Unity-project folder or when I use the function that I need, Unity crashes and I can't open the project untile I remove the .dll or delete the function from the c# script.
This function works well on C++, both in Visual Studio and in Dev-C++ .
PS: Assets/alzBraccioCorretto.json is the file that I need to read
I've tried the same procedure for more simple dlls and it worked fine, so I don't know what I'm missing with this one.
In the Unity script I wrote
[DllImport("QuintaLibreria.dll", CharSet = CharSet.Unicode)]
static extern int LockOn(string filename, double lsxx, double lsxy, double udxx, double udxy, double
timer);
int temp = LockOn("Assets/alzBraccioCorretto.json", -1, -1, 1, 1, 6);
In the header of the library I have
#define MATCHINGLIBRARY_API __declspec(dllexport)
//all the other headers and #include
extern "C" {
MATCHINGLIBRARY_API int LockOn(string filename, double lsxx, double lsxy, double udxx, double
udxy, double timer);}
In the cpp of the library I have
MATCHINGLIBRARY_API int LockOn(string filename, double lsxx, double lsxy,
double udxx, double udxy, double timer) {
char * FileName = new char[filename.size() + 1];
std::copy(filename.begin(), filename.end(), FileName);
FileName[filename.size()] = '\0';
return lockPerson(FileName, lsxx, lsxy, udxx, udxy, timer);
}
↧