Other than using Visual C++ 2010 in Matlab, we can also use MingGW, the GNU compiler for compiling c/c++ files in Matlab with mex in Windows Environment.
1.) Download gnumex, and install it as if a toolbox, and download the MingGW.
2.) run gnumex in Matlab command windows, a GUI is shown.
3.) Follow the on-screen instruction