I am writing a dll (with C++) for use with matlab. The dll has several function calls which look like this:
int8 function1(paraStruct* const Params);
The first weeks the dll worked fine, but as development continued the Params structure grew larger, and at some point matlab started to behave erratic:
-it crashed about 20 seconds after loading the dll with loadlibrary without any warning (the logfile was empty). -I got segmentation vaults when calling functions -the dll did not return correct data
None of these problem occurred when I called the dll from another C++ program, so I'm quite sure matlab is at least part of the problem. I'm using matlab R2007b, but a coworker had similar problems with R2010b.
At the moment, the structure looks like this:
typedef struct { uint16 u16_Depth; uint16 u16_Width; uint16 u16_Height; uint16* pu16_InData; uint16* pu16_OutData; uint16 u16_Start; uint16 u16_End; uint16 u16_Flags; uint8 u8_NR_Algorithm; uint8 u8_NR_Border; uint8 u8_NR_Width; uint8 u8_NR_Height; float32 f32_NR_Sigma; uint8 u8_HR_Algorithm; uint8 u8_HR_Flags; float32 f32_HR_Area; float32 f32_CA_Intensity; uint16 u16_CA_Height; uint16 u16_CA_Border; uint8 u8_CA_Flags; uint8 u8_ED_Line; uint8 u8_ED_Algorithm; uint8 u8_ED_Flags; uint8 u8_ED_Mode; int16* pi16_ED_CustomMode; uint8 u8_ED_Border; uint16 u16_ED_Width; uint16 u16_ED_Height; float32* pf32_ED_Sigma; uint8 u8_ED_Meta; uint8 u8_ED_Upper; uint8 u8_ED_Lower; float32* pf32_ED_UpperList; float32* pf32_ED_LowerList; float32 f32_ED_Start; float32 f32_ED_End; uint16 u16_ED_Number; } paraStruct;
When I remove some values from the struct (i.e. all ED values) it works again, but of course only with limited functionality.
Is there some way to persuade matlab to work with such abundand structures, or at least some feasible workarount?
Yours, Lasse
Best Answer