×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources