MATLAB: Are 32-bit MEX-files supported for 64-bit MATLAB running on Windows XP x64

3264bitcompilerdllloadlibraryMATLAB

I would like to call my MEX-function myfunc.mexw32 that I compiled on a 32-bit version of MATLAB 7.2 (R2006a) from a 64-bit Windows machine running 64-bit MATLAB 7.2 (R2006a). However, when I issue the following at the MATLAB command prompt:
myfunc
I receive the following error:
??? Undefined function or variable 'myfunc'.
I have verified that myfunc.mexw32 is in my current work directory. I would like to know how to successfully call this function from my 64-bit Windows machine.

Best Answer

It is not possible to run a 32-bit MEX-file from within a 64-bit version of MATLAB. This is because MEX-files are shared libraries and it is not possible to call a 32-bit shared library from a 64-bit application (or vice versa).
To work around this issue, you will need to start the 32-bit version of MATLAB. Please note that this mode is not fully supported, but should work in most cases. You will need to have the 32-bit version of MATLAB installed for this to work.
If you do have the 32-bit MATLAB installed on your 64-bit machine, you can launch the 32-bit version of MATLAB, and then call the MEX file from the command prompt.
Alternatively, if you have the source code for the MEX file, you can compile it into a 64-bit MEX file from the 64-bit version of MATLAB. To do so, you need to have a supported 64-bit compiler installed on your machine. Please refer to the following link to identify the compilers supported by the MEX interface of MATLAB R2006a on 64-bit Windows machines: