Build MEX function from C/C++ or Fortran source code - MATLAB mex
This MATLAB function compiles and links one or more C, C++, or Fortran source files into a binary MEX file, callable from MATLAB. ... You can link to object files that you compile separately from your source MEX files. The MEX file example, fulltosparse, ...