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

1 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by