MATLAB: Cannot find MEX function when executing C

MATLAB Compilermccmex-functionruntime error

System
  • Ubuntu running R2010a
Error
  • Undefined function or method 'mex' for input arguments of type 'char'.
Compilation call
/usr/local/matlab/bin/mcc -m -v -R -nodisplay remote_estimation.m
Context
  • Compiling .m file that has the follwing code:
function remote_estimation()
%#function mex
mex('/path/to/file.c');
When executing in matlab it works, after compiling and executing the binary, it gives the error described above

Best Answer

The mex command does not perform magic tricks, it simply starts the compiler. Unfortunately mex has grown to a very obfuscated piece of code since Matlab 4. It are some M-, Perl- and BAT-files, while the last are not executed, but parsed by teh Perl functions.
If you find out the parameters used for starting the compiler, you can start the compiler by a single system call also.