Calling mex Function from Python extension
44 ビュー (過去 30 日間)
I am trying to write a Python extension program to call a MATLAB mex function. What I want to do is to have my program directly call the function mexFunction(...) with my own mxArray parameters, etc.
When I run the program in Python I get a DLL load error. After some experimenting I found that if I comment out the include statement for mex.h the program loads fine, but as soon as I include mex.h I get the DLL load error again.
My theory is that there is a DLL conflict because the program as been declared to be both a Python DLL and a MATLAB DLL and the system gets confused. I tried going into the mex.h file and commenting out the DLL_EXPORT command hoping I could trick it, but that didn't help. So now I'm thinking that maybe it is still getting declared as a DLL in the MATLAB lib files, but that is just a guess.
The bottom line is this. I basically want to be able to call a mex function from my own program similar to how MATLAB would call the function, passing in the mxArray variables and other parameters. I assume they are doing something like a call to LoadLibrary followed by GetProcAddress. How can I do something similar without it thinking that this is a DLL?
回答 (1 件)
Bo Li 2016 年 9 月 22 日
How do you want to invoke this MEX file? From inside MATLAB or in Python? You can use mxArray in Python without using MEX. Or you can use Python Interface to invoke the Python extension directly from MATLAB: