Linking error when building without CRT, memcpy and memset intrinsic functions

/Oi is not documented as necessarily inserting all intrinsics where possible, instead it merely gives the compiler the option of doing so. I haven't been able to figure out what logic MSVC uses to reach its final conclusion, but some factors include the project mode (it's far more likely to inject the intrinsics in RELEASE as compared to DEBUG) and the length of your functions.

Recent versions of Visual Studio really have integrated MSVCRT dependencies into the compiler and it's become increasingly harder to generate code that does not depend on the standard C runtime.

The standard way of working around these issues (though extremely looked down upon by Microsoft) is to link against the system copy of MSVCRT.dll, which ships in some form or the other with all versions of Windows. So long as you are using standard C functions like memset you can soundly ignore Microsoft's piercing glares of disapproval and link away to your heart's content, but don't try to use it for more complicated functions and APIs provided by the CRT.

To link against msvcrt.dll you'll need to either use LoadLibrary and co or else use a pre-generated msvcrt.lib (Microsoft purposely does not provide one) to tell MSVC which functions are available in the system MSCRT.dll


Update: we now publish precreated mscvrt.lib files for statically linking against the CRT (at your own risk!) for x86 and x64 platforms: https://github.com/neosmart/msvcrt.lib