Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ dll, mex files, and loadlibrary - need help with error

Status
Not open for further replies.

Bruit

Computer
Oct 14, 2010
7
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top