Some shared libraries, compiled as Microsoft® Windows® 32-bit libraries, use a calling convention that is incompatible with the default MATLAB® calling convention. The default calling convention for MATLAB and for Microsoft C and C++ compilers is cdecl. For more informations, see the MSDN® Calling Conventions article.
If your library uses a different calling convention, you must create a loadlibrary prototype file and modify it with the correct settings, as described in http://www.mathworks.com/matlabcentral/answers/96578-why-does-matlab-crash-when-i-make-a-function-call-on-a-dll-in-matlab-7-6-r2008a.
For information about creating prototype files, see MATLAB Prototype Files.