Bruit
Computer
- Oct 14, 2010
- 7
I'm having trouble using a C++ dll in matlab
I have tried loadlibrary but couldn't get it to work. I keep getting this error message:
undefined reference to '_loadlibrary'
undefined reference to '_calllib'
I can't find info on this error searching online,forums or through the matlab documentation. Could someone tell me what I'm doing wrong or at least give me a hint as to what the error means?
Here is my mex file:
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ){
double *out;
int *in;
out = mxCreateDoubleMatrix(1, 1, mxREAL);
out = mxGetPr(plhs[0]);
in = mxGetPr(prhs[0]);
loadlibrary('PortInterface.dll','PortInterface.h');
out = (double *) calllib('PortInterface', 'PortRead', in);
return;
}
--------------------------------
and here is the header file PortInterface.h:
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
short PortRead(short Rack, short Port, short Offset);
void PortWrite(short Rack, short Port, short Offset, short Value);
#ifdef __cplusplus
}
#endif
I have tried loadlibrary but couldn't get it to work. I keep getting this error message:
undefined reference to '_loadlibrary'
undefined reference to '_calllib'
I can't find info on this error searching online,forums or through the matlab documentation. Could someone tell me what I'm doing wrong or at least give me a hint as to what the error means?
Here is my mex file:
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ){
double *out;
int *in;
out = mxCreateDoubleMatrix(1, 1, mxREAL);
out = mxGetPr(plhs[0]);
in = mxGetPr(prhs[0]);
loadlibrary('PortInterface.dll','PortInterface.h');
out = (double *) calllib('PortInterface', 'PortRead', in);
return;
}
--------------------------------
and here is the header file PortInterface.h:
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
short PortRead(short Rack, short Port, short Offset);
void PortWrite(short Rack, short Port, short Offset, short Value);
#ifdef __cplusplus
}
#endif