MATLAB: Does the MATLAB Compiler standalone application fail to start with a “The operating system cannot run %1.” error

MATLAB Compiler

I have created a MATLAB Compiler standalone application without any errors during compilation. When I try to run the application I receive the following error however:
ERROR: Fatal Internal Error: std::exception: Loading C:\Program Files\MATLAB\R2017a\bin\win64\matlab_startup_plugins\lmgrimpl\libmwlmgrimpl.dll failed with error: The operating system cannot run %1.

Best Answer

This error may occur if you have an older version of ssleay32.dll and libeay32.dll in your Windows system32 directory. To resolve this issue, either:
1. Place a copy of MATLAB's SSLEAY32.DLL and LIBEAY32.DLL (from the bin\win64 directory) next to your standalone executable. The directory from which the application loaded has a higher priority than system32, so this should allow the application to use the DLLs which it needs, or
 
2. Remove SSLEAY32.DLL and LIBEAY32.DLL from the system32 directory; the standalone can then use the one included with MATLAB. This may break other applications however which rely on the DLL being in system32. So, alternatively you may want to update SSLEAY32.DLL and LIBEAY32.DLL in the system32 directory, for example by replacing it with the copies included with MATLAB or perhaps you could update the application which installed this DLLs in the first place, if you know which application this was.
PS: To identify that this is indeed the cause of the issue you can run a Dependency Walker profile on the standalone application, in which you would see  ssleay32.dll and libeay32.dll being loaded from a different location than MATLAB/MCR bin\win64 directory and you should see that certain entry points are not found in that DLL. Note that this occurs way before libmwlmgrimpl.dll is loaded, it happens when the POCO libraries are loaded first and then libmwlmgrimpl.dll fails when it tries to use these POCO libraries.