Linker Tools Warning LNK4210

section section exists; there may be unhandled static initializers or terminators

Some code introduced static initializers or terminators, but the CRT or its equivalent (which needs to run the static initializers or terminators) isn't run when the application starts. Examples of code that would cause this:

  • Global class variable with a constructor, destructor, or virtual function table.

  • Global variable initialized with a non-compile-time constant.

To fix this problem, try one of the following:

  • Remove all code with static initializers.

  • Do not use /NOENTRY. After you remove /NOENTRY, you may also have to add msvcrt.lib, libcmt.lib, or libcmtd.lib to your linker command line.

  • Add msvcrt.lib, libcmt.lib, or libcmtd.lib to your linker command line.

  • When moving from /clr:pure compilation to /clr, remove the /ENTRY option from the linker-line. This will enable CRT initialization allowing static initializers to be executed at application startup.

  • If your project is built with /ENTRY, and if /ENTRY is passed a function other than _DllMainCRTStartup, the function must call CRT_INIT. See Run-Time Library Behavior and Knowledge Base article Q94248, https://support.microsoft.com/default.aspx?scid=kb;en-us;94248 for more information.

The /GS compiler option requires CRT startup code.

See Also

Reference

Setting Linker Options