Here I've got a dll written in C downloaded from the internet. The library is successfully loaded in Qt, functions resolved. But calling these methods causes the app to crash with "Segmentation fault". Besides, I've built a C# project in VS08 and loaded the library. Everything works again.
Here's the code:
1.dll library:
void fdlib_detectfaces(unsigned char *imagedata, int imagewidth, int imageheight, int threshold);
2.Qt app:
3.C# implementation:Code:
ushort graydata[10*10]; bool okLoad = mylib.load(); bool loaded = mylib.isLoaded(); typedef void (*FdetectFace)(ushort*,int,int,int); FdetectFace detectFace = (FdetectFace)mylib.resolve("fdlib_detectfaces"); //app crashes here detectFace(&graydata[0],10,10,0);
[DllImport("fdlib.dll")]
Code:
unsafe public static extern void fdlib_detectfaces(ushort*data,int w,int h,int threshold); public static void TestFace() { unsafe { UInt16[] image = new ushort[10 * 10]; fixed (ushort* ptr = &image[0]) { fdlib_detectfaces(ptr, 10, 10, 0); } } }
