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