To compile and link the source files written in C, at the MATLAB prompt, type the command mex. This will create a mexsol file, which will behave exactly like an M-file in MATLAB. You can also combine several object and use libraries while building MEX-file