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.>>