MATLAB: Whats the difference between a mex file and a dll

dllmex

Whats the difference between a mex file and a dll? How does the different versions of Matlab treat them?

Best Answer

Compiled MEX files are DLLs with a special entry function "mexFunction" as gateway to MATLAB. DLLs without this gateway need the CALLLIB command to be run.
In older Matlab versions, MEX-DLLs used the file extension .dll, but today there are different extension to avoid confusion between the different systems, e.g. .mexw32 and .mexw64 for the 32 and 64 bit Windows versions.
Old Matlab versions cannot run MEX files compiled for modern versions. Old DLL files compiled with Matlab 6.5 can be executed by modern Matlab 32 bit versions, but the support will be (or is already?) stopped. Then a recompilation of the C/C++/Fortran-sources is required. MEX files compiled with 32 bit systems can be run in 32 bit systems only, the same for 64 bits.
If you have a specific question, answering would be easier.
Related Question