Metis and metismex for matlab win7 x64

I have been trying for a long time to use metis from inside matlab, so I found metismex.
But, I couldnt compile it from Matlab.
After a long time, a solution was found and now I can use metis from inside matlab perfectly.
I thought this would be of interest to people using metis, so here it goes:
(Not taking credit for solution though. Not mine)

Use metis from matlab with metismex in a win7 x64 machine.

(Tested and working in Matlab R2013 and MS Visual Studio 11 2012)

Download and extract metis-5.0.2 to some location, say C:\metis-5.0.2. Personally, I downloaded the patched version of Metis, described here : http://glaros.dtc.umn.edu/gkhome/node/1095

(patched version here: https://github.com/helixhorned/metis/tree/pk )

a. Compile Metis
1.First from Cmake gui, generate visual studio project, selecting as compiler "Visual Studio 11 2012 x64)
2.Then we have to get rid of rint redefinitions. So, remove them from metisbin.h,metislib.h and gk_arch.h.
( So we remove code such
as #ifdef _MSC_
#define rint(x) ((int)((x)+0.5))
#endif )
3. In GKlib\gk_externs.h replace occurences of __thread with __declspec(thread)
4. Open metis.sln in Visual Studio and create new configuration for x64 ( Build->Configuration Manager and "new" -> select x64)
5. Compile it, and we are ready. Result should be in a folder such as "build\libmetis\Release\metis.lib". The executables in "build\programs\Release"

b.Now, proceed with metismex :
1. Extract metismex in a subfolder of metis.
2. Rename metismex.c to metismex.cpp
3. Edit metismex.cpp and change to
4. Immediately after #include add this :
#if defined(_WIN32) || defined(_WIN64)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#endif

Finaly, start matlab, cd to metismex folder and
mex -o -largeArrayDims -DWIN32 -DMSC -DUSE_GKREGEX -I../GKlib -I../include -I../libmetis metismex.cpp ../build/libmetis/Release/metis.lib (where ../build/libmetis/...etc etc is the directory of compiled metis.lib in your computer)

RE: addition

Sorry forgot something :
In compiling metismex, section 3 :

Edit metismex.cpp and change strings.h to string.h