Hello,
When using the "coder" app to generate mex files directly the result is still too slow. However when one uses the coder app to generate C code they are given the option to optimize for code speed rather than build time (this option is not available for mex files). So I hypothesize that when building mex files directly "coder" optimizes build time rather than speed and that's why it is slow. Hence I would like to build a mex file from the C code.
However the help files for the "mex" function are no help and neither are the help pages purporting to show compiling a mex file from C source files (the situations described are not similar enough). I clicked the option to generate only one C file but it still produces many. Even when I include all of the C files it wont compile. I think I need to include other files, such as .h files or files from the "interface" directory.
The function I am trying to mex is the the "autocov_to_var" function from the MVGC toolbox: <http://users.sussex.ac.uk/~lionelb/MVGC/>
When I run coder to generate C files and tell it to produce only 1 C file the result is the directory below:
From that directory I tried the call:
mex autocov_to_var.c rt_nonfinite.c rtGetInf.c rtGetNaN.c
and got:
Building with 'MinGW64 Compiler (C)'. Error using mex Cannot export mexFunction: symbol not defined collect2.exe: error: ld returned 1 exit status
What files do I need to include in my call to mex? (Is there a better way to ensure my mex file is as fast as humanly (err MatLab-anly) possible?)
Best Answer