• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 923
  • Last Modified:

Attempt to call dll function from matlab causing crash

I'm trying to use a third-party external DLL (from usbmicro) within matlab, but it keeps crashing matlab. This is from the documentation indicating the syntax of the function call from within a C program:

int USBm_About( char *about );

I tried this matlab script (yes it's very kludgy, I'm a matlab noob):
 
>> loadlibrary('USBm.dll','USBmAPI.h')
>> libfunctions('USBm')
>> s='sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss';
>> st=strcat(s,s,s,s);
>> vp = libpointer('voidPtr',[int8(st) 0]);
>> result=calllib('USBm','USBm_About',vp)

Open in new window


and this matlab script:
 
>> loadlibrary('USBm.dll','USBmAPI.h')
>> libfunctions('USBm')
>> s='sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss';
>> st=strcat(s,s,s,s);
>> vp=libpointer('cstring',st);
>> result=calllib('USBm','USBm_About',vp)

Open in new window


In both cases, the calllib() call causes matlab to crash with a segmentation fault.
0
opike
Asked:
opike
  • 2
2 Solutions
 
grayeCommented:
I presume you'd tried the simple approach first?

result=calllib('USBm','USBm_About',st)
0
 
opikeAuthor Commented:
We never figured this out but we moved on to something else.

Awarding the points in appreciation of the attempt.
0
 
opikeAuthor Commented:
Went unresolved but awarding points in appreciation.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now