Sclib unable to link in HC 2023

Microsoft made a change that may require additional link options (cf. Microsoft Developer Community post __imp___std_init_once_complete unresolved external symbol after linking msvcprtd.lib).

For example, building a sample (e.g. authoring_samples.sln) with the authoring library (i.e. sc.lib) in release mode produces

unresolved external symbol __imp___std_init_once_begin_initialize
unresolved external symbol __imp___std_init_once_complete

In debug, the link errors are as follows;

This problem may be sensitive to the versions of Visual Studio, the toolset and SDK version.

The following version of Visual Studio:

Microsoft Visual Studio Professional 2019
Version 16.11.15

with the following properties:

SDK version: 10.0 (latest installed version)
Platform toolset: Visual Studio 2019 (v142)

does not have this problem. It builds and links successfully.

If you experience these errors, you should the the version details mentioned.

Alternatively, adding these two lines to the link line fixes the problem:

/ALTERNATENAME:__imp___std_init_once_begin_initialize=__imp_InitOnceBeginInitialize /ALTERNATENAME:__imp___std_init_once_complete=__imp_InitOnceComplete

See also the Microsoft article C++ binary compatibility 2015-2022.