MATLAB: Using mex to compile with \clr option

\clrcmex

I am trying to call a custom C++ library from Matlab. I can build this library in Visual Studio 2010 and run just fine. However, when I try to build with mex to call from Matlab I get the following fatal error:
C1190: managed targeted code requires a'/clr' option
I cannot tell in the mex documentation if adding this compiler flag is doable. Or what my options are to talk with this C++ library.
Help!

Best Answer

Adding a compiler flag to the mex process can be accomplished like this:
filename = your source code file name
compiler_option = '/clr';
mex(filename,['COMPFLAGS="$COMPFLAGS ' compiler_option '"']);
Related Question