Mex files call DLL generated by .m file
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Qun Wu
el 24 de Ag. de 2017
Respondida: Harsheel
el 1 de Sept. de 2017
I have a myfile6.m function, it is a generic function with 1 input and 1 output. By following command:
mcc -W cpplib:YourLib -T link:lib myfile6.m
a bunch of files are generated:
YourLib.cpp
YourLib.def
YourLib.dll
YourLib.exp
YourLib.exports
YourLib.h
YourLib.lib
And then I try to link the .dll in my Mex file. I watched a lot of tutorial videos. One method is using LoadLibrary function, and a pointer which is to the address of the exported function in the DLL. The code looks like this:
#include <mex.h>
#include <windows.h>
typedef int(__stdcall *func_ptr)();
HINSTANCE hGetProcIDDLL = LoadLibrary(".dll file path") // double back slash
However, the example in videos are relatively simple. They have an explicit function in the source cpp file. Thus in this condition, we can directly use GetProcAddress function as following:
func_ptr funP = (fun_ptr)GetProcAddress(hGetProcIDDLL, "DLLfun");
When I open the generated source cpp file. It looks not easy since I am newie for matlab coding. I do not know how to put the second argument of the GetProcAddress function. I will upload the .cpp file and .h file. Could you please give me some suggestions? Or if the entire idea is wrong, please let me know. Thank you.
Qun
0 comentarios
Respuesta aceptada
Harsheel
el 1 de Sept. de 2017
You cannot load a MATLAB Compiler SDK generated shared library back into MATLAB. This is currently unsupported and is mentioned in the doc here.
All the sample code from above link is available in the $matlabroot\extern\examples\compilersdk folder.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Compiler en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!