Application statically linked with Visual C++ 2010 C/C++ runtime fails to launch with error ‘The procedure entry point EncodePointer could not be located in the dynamic link library KERNEL32.dll’.


Symptoms


 

Your application fails to launch with the error

‘The procedure entry point EncodePointer could not be located in the dynamic link library KERNEL32.dll’. 

Cause


 

The Visual C++ 2010 C/C++ runtime relies on APIs introduced in Windows XP SP2, including the “EncodePointer” API indicated in the error message.  Any application that statically links with this version of the C/C++ runtime will not load successfully on versions of Windows prior to Windows XP SP2, as the Windows loader will fail to locate the proper API exports required by the application.

Note that both Microsoft Foundation Classes (MFC) and the C++ Standard Template Library (STL) internally make use of the C/C++ runtime, so applications that statically link the runtime and use MFC or STL but do not explicitly use the C/C++ runtime in the user code will still encounter this failure.

Resolution


 

The best fix for this issue is to stop statically linking the C/C++ runtime into the application, and instead rely on the runtime installed on the host OS, as this version of the runtime will be matched properly to the APIs exposed by the particular version of the OS.

If there are business, deployment, or other technical reasons why you need to continue statically linking the C/C++ runtime into your application, you will either need to a) revert to using a version of the runtime shipped with versions of Visual C++ 2008 SP1 or earlier; or b) keep using the 2010 version of the runtime and require that Windows XP SP2 is a minimum requirement for your application.