Configure mex compiler either C or C++ by using MATLAB command in the command window
mex –setup C / C++
This will automatically set to default C / C++ compiler in the hardware if only one compiler is present else it displays a list of compilers and a compiler has to be chosen.
Create a gateway routine mexFunction in the main file and include mex.h header file.
Call the main function inside the mexFunction.
Create a MATLAB executable to the main function by using MATLAB Command
mex main.c
Run the executable (main) in the command window
The above documentation provides a C-Mex standalone example for gateway routine mexFunction implementation