LMNN: How to install

LMNN stand for large margin nearest neighbor [1].
There is this nice page about Metric Learning codes which are available online. http://www.cs.cmu.edu/~liuy/distlearn.htm
It took time to get LMNN to work. At the end I end up using lmnn2 from http://www.cse.wustl.edu/~kilian/code/files/mLMNN.zip
After unzipping, you should run install.m to compile all the C++ files (I have window I assume that you need to run installWINDOWS.m). In my case since I had GCC 4.6.x and the latest supported GCC by MATLAB is 4.3.4, I gave me some warnings. Just ignore those. You get an error that stack.h is not found. Just change
#include <stack.h>
to
#include <stack>
using namespace std;
That should solve the problem.
[1] http://books.nips.cc/papers/files/nips18/NIPS2005_0265.pdf