I change the gcc command in the first line to g++. The references error vanished, but now I seem to have library connection problem! :-(
The code in the Makefile is bold and the errors are highlighted in red.

Code:
gcc -O3 -ffast-math -fomit-frame-pointer -fPIC -m64  -DKMEANS_VERBOSE=0   -c -o mpi_kmeans.o mpi_kmeans.cxx
g++ -shared -fPIC -O3 -ffast-math -fomit-frame-pointer -fPIC -m64  -DKMEANS_VERBOSE=0  -o mpi_kmeans.o   mpi_kmeans.cxx
ar rc libmpikmeans.a mpi_kmeans.o
/usr/bin/ranlib: file: libmpikmeans.a(mpi_kmeans.o) is a dynamic library, not added to the static library
ranlib libmpikmeans.a
ranlib: file: libmpikmeans.a(mpi_kmeans.o) is a dynamic library, not added to the static library
ranlib: empty library: libmpikmeans.a (no table of contents added)
gcc -O3 -ffast-math -fomit-frame-pointer -fPIC -m64  -I/Applications/MATLAB_R2012b.app/extern/include -DKMEANS_VERBOSE=0   -c mpi_kmeans_mex.cxx -o mpi_kmeans_mex.o
g++ mpi_kmeans_mex.o -shared -m64 -o mpi_kmeans_mex.mexmaci64 libmpikmeans.a -L/Applications/MATLAB_R2012b.app/bin/maci64 -lmex 
ld: warning: in libmpikmeans.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
  "_mxGetM", referenced from:
      _mexFunction in mpi_kmeans_mex.o
........