How do I call a function that resides in a DLL from a CMEX DLL?

1 view (last 30 days)
How do I call a function that resides in a DLL from a CMEX DLL?
I am trying to write a CMEX file to call from the MATLAB command line. I have been successful at completing this task in the past. However, this time I am trying to call a function that resides in a DLL and now I am not able to do this.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The general format for linking multiple objects is:
mex circle.c square.obj rectangle.c shapes.lib
NOTE: The MEX command compiles code using the "__cdecl" calling convention. Compiling the dll using the "__stdcall" calling convention.would lead to an error. To get the linking process to work, you need to do two things when compiling your dll:
1) Change the calling convention to "__cdecl" and
2) Export the dll function using the following: extern "C" __declspec(dllexport)

More Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!