The reason why mxCreateNumericArray returns NULL is because MCR is not initialized in Windows application C code.
In order to make it work, call the 'mclInitializeApplication' routine. Make sure that the application was initialized properly by checking the return status.
This initialization has to be done before calling any MATLAB APIs or MATLAB Compiler SDK generated shared library functions.
if( !mclInitializeApplication(NULL,0) )
{
fprintf(stderr, "Could not initialize the application.\n");
return -1;
}
The following document explains step-by-step guide to integrate a C shared library into a Windows Application-
Best Answer