MATLAB: Can an end user without Matlab license use an executable containing the mex command

MATLAB Compilermex executable compiler visual studio 2010 exe

I have done a Matlab executable which uses the mex command:
eg. system('mex -v -g -LC:\Example\Release -lModel Test.c Test_wrapper.c')
I intend to use it as a standalone exe in a target computer which doesn't have Matlab.
I've installed the correspondent version of MCR in the target computer.
The .exe works fine on my computer, however, when I try to run it on the target computer from the command line, the following message pops up:
" 'mex' is not recognized as an internal or external command, operable programm or batch file "
Am I missing something here? Is it not possible to run a .exe containing Matlab commands on a target machine without Matlab?
On my computer i have:
  • Matlab 2011b (32bit and 64bit, application is compiled using the 32bit)
  • Visual Studio 2010 Ultimate
  • Windows 7 (x64)
On target computer:
  • Visual Studio 2010 Ultimate
  • Windows XP (x64)
Any help will be highly appreciated! Thanks in advance!

Best Answer

Hi, here's the answer from Matlab support, I thought it is worthwhile publishing it if anyone has had the same idea as me. Thanks everybody for your help!
<<MATLAB Compiler does not support the MEX function; now it looks like you somehow try to work around that by calling MEX externally. Which may perhaps work if you have a full MATLAB installation, but the external MEX command definitely is not included in the MATLAB Compiler Runtime (MCR).
If you somehow want to be able to call dynamically generated/compiled C/C++ code from your MATLAB Compiler application you will need to do the following:
1. Implement the dynamic part of the C/C++ code in a separate DLL which you compile by yourself using an external compiler.
2. Implement a MEX-file which uses the operating system's LoadLibrary and GetProcAddress to call this external DLL.
The MEX-file then gets compiled into your MATLAB Compiler standalone and the external DLL can be kept external and recreated and recompiled using your own compiler; of course this compiler can be called from within your MATLAB code using the DOS/SYSTEM function.>>