# CMake bootstrap fails under Windows with error: 'KWSYS\_ENCODING\_DEFAULT\_CODEPAGE' was not declared in this scope

**URL:** https://discourse.cmake.org/t/cmake-bootstrap-fails-under-windows-with-error-kwsys-encoding-default-codepage-was-not-declared-in-this-scope/13586
**Category:** Development
**Tags:** os:windows
**Created:** [February 16, 2025, 1:33pm UTC](https://discourse.cmake.org/t/cmake-bootstrap-fails-under-windows-with-error-kwsys-encoding-default-codepage-was-not-declared-in-this-scope/13586 "2025-02-16T13:33:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Benjamin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/3d9bf3/32.png) [@Benjamin](https://discourse.cmake.org/u/Benjamin)
#### Post date: [February 16, 2025, 1:33pm UTC](https://discourse.cmake.org/t/cmake-bootstrap-fails-under-windows-with-error-kwsys-encoding-default-codepage-was-not-declared-in-this-scope/13586/1 "2025-02-16T13:33:47Z")

</div>

Hey there,  
I am trying to build CMake master branch from scratch as described here:  
[https://gitlab.kitware.com/cmake/cmake/-/blob/master/README.rst#building-cmake](https://gitlab.kitware.com/cmake/cmake/-/blob/master/README.rst#building-cmake)  
I am on Windows 10 and try to build with MSYS2 & MinGW.

I installed the necessary MSYS packages with  
`pacman -S --needed git base-devel mingw-w64-x86_64-gcc`

Unfortunately the bootstrap script fails with the following error:

`C:/Projects/cmake/Source/cmProcessOutput.cxx:12:3: error: 'KWSYS_ENCODING_DEFAULT_CODEPAGE' was not delared in this scope`

Do I have to define that manually when calling bootstrap?  
It seems to get set to ‘CP\_UTF8’ in the top level CMakeLists.txt, but I do not know if and when this gets executed when calling bootstrap…

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [February 17, 2025, 2:46pm UTC](https://discourse.cmake.org/t/cmake-bootstrap-fails-under-windows-with-error-kwsys-encoding-default-codepage-was-not-declared-in-this-scope/13586/2 "2025-02-17T14:46:52Z")

</div>

During `bootstrap`, `KWSYS_ENCODING_DEFAULT_CODEPAGE` is supposed to be defined [here](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.31.5/bootstrap#L1693). The condition guarding it is that `uname`’s output contains `MINGW`.

To use the `mingw-w64-x86_64-gcc` toolchain and build for MinGW, rather than the MSYS2 runtime, be sure to bootstrap in MinGW development environment:

```console
$ echo $MSYSTEM
MINGW64

```

---

<div class="post-metadata">

### Author: ![Benjamin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/3d9bf3/32.png) [@Benjamin](https://discourse.cmake.org/u/Benjamin)
#### Post date: [February 18, 2025, 5:03pm UTC](https://discourse.cmake.org/t/cmake-bootstrap-fails-under-windows-with-error-kwsys-encoding-default-codepage-was-not-declared-in-this-scope/13586/3 "2025-02-18T17:03:43Z")

</div>

That brings me a big step further, thank you very much!  
(What I ended up doing was to simply start mingw64.exe instead of msys2.exe in my msys installation which starts the MinGW environment and automatically sets the right environment variables.)

When I use that environment, bootstrap and make succeeds.  
Unfortunately, that is when I run into a new problem.

When trying to run build/cmake.exe, an error message appears, stating that  
" The Procedure Entry Point “_ZNKSt7codecvtlcciE5do\_inERiPKcS3\_RS3\_PcS5\_RS5_” Could Not Be Located in the Dynamic Link Library “C:\Projects\cmake\build\bin\cmake.exe”.

I guess I miss some DLL?  
The following DLLs have been copied to the build dir, but it seems they are insufficient or the incorrect libs:

libcmake.dll.a  
libcmcldeps.dll.a  
libcpack.dll.a  
libctest.dll.a
