lolcat
lolcat

Reputation: 655

Building the Windows Universal C Runtime

I am trying to build the Universal C Runtime that comes with the Windows 10 SDK.

I created a project and added source code from this directory:

%ProgramFiles(x86)%\Windows Kits\10\Source\10.0.16299.0\ucrt

I encountered errors. I followed and fixed the trail of errors. But eventually I got errors about overloaded functions and missing headers that don't seem to exist on my computer:

(ClCompile target) ->
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2556: '__crt_stat
e_management::dual_state_global<int> *__p__fmode(void)': overloaded function differs only by return type from 'int *__p
__fmode(void)' [C:\src\ucrt\build\time.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2371: '__p__fmode
': redefinition; different basic types [C:\src\ucrt\build\time.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(1920): fatal error C1083: Cann
ot open include file: 'corecrt_internal_state_isolation.h': No such file or directory [C:\src\ucrt\build\ti
me.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2556: '__crt_stat
e_management::dual_state_global<int> *__p__fmode(void)': overloaded function differs only by return type from 'int *__p
__fmode(void)' [C:\src\ucrt\build\time.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2371: '__p__fmode
': redefinition; different basic types [C:\src\ucrt\build\time.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(1920): fatal error C1083: Cann
ot open include file: 'corecrt_internal_state_isolation.h': No such file or directory [C:\src\ucrt\build\ti
me.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2556: '__crt_stat
e_management::dual_state_global<int> *__p__fmode(void)': overloaded function differs only by return type from 'int *__p
__fmode(void)' [C:\src\ucrt\build\time.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2371: '__p__fmode
': redefinition; different basic types [C:\src\ucrt\build\time.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(1920): fatal error C1083: Cann
ot open include file: 'corecrt_internal_state_isolation.h': No such file or directory [C:\src\ucrt\build\ti
me.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2556: '__crt_stat
e_management::dual_state_global<int> *__p__fmode(void)': overloaded function differs only by return type from 'int *__p
__fmode(void)' [C:\src\ucrt\build\time.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2371: '__p__fmode
': redefinition; different basic types [C:\src\ucrt\build\time.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(1920): fatal error C1083: Cann
ot open include file: 'corecrt_internal_state_isolation.h': No such file or directory [C:\src\ucrt\build\ti
me.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Source\10.0.16299.0\ucrt\inc\corecrt_internal.h(102): error C2556: '__crt_stat
e_management::dual_state_global<int> *__p__fmode(void)': overloaded function differs only by return type from 'int *__p
__fmode(void)' [C:\src\ucrt\build\time.vcxproj]
...

I wasn't able to find any documentation about building the Universal C Runtime.

Am I on the wrong track? Any advice is appreciated.

Upvotes: 1

Views: 1512

Answers (1)

Simon Kissane
Simon Kissane

Reputation: 5338

2024 Update: Someone on GitHub appears to have worked out the needed changes to get UCRT to build outside of Microsoft, see the repo huangqinjin/ucrt. The necessary changes were merged in a May 2024 PR, including a reimplementation of the missing corecrt_internal_state_isolation.h header. In related news, Microsoft has released the UCRT sources under the MIT license.


In older versions, Microsoft shipped the full C runtime source, and it was possible to rebuild it yourself. However, in more recent versions, Microsoft has removed support for rebuilding it outside of Microsoft (source). Part of how they have done that, is by not shipping certain key files required to build it, such as corecrt_internal_state_isolation.h (as you've discovered).

If you just want to change one particular file, you may be able to (with some hacking) recompile just that file – see this blog post for an example.

In theory, one could construct something functionally equivalent to any missing files (including corecrt_internal_state_isolation.h) through trial and error, intelligent guesswork, maybe even some reverse engineering of the binary. It would be a lot of work, but maybe someday someone out there will feel attracted to the challenge.

Upvotes: 1

Related Questions