# CMake can't load the standard library for Swift on Windows

**URL:** <https://forums.swift.org/t/cmake-cant-load-the-standard-library-for-swift-on-windows/34605>\
**Category:** Using Swift\
**Tags:** windows, cmake\
**Created:** [March 18, 2020, 5:50am UTC](https://forums.swift.org/t/cmake-cant-load-the-standard-library-for-swift-on-windows/34605 "2020-03-18T05:50:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![atirit](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/atirit/32/10884_2.png) [@atirit](https://forums.swift.org/u/atirit)\
**Post date:** [March 18, 2020, 5:50am UTC](https://forums.swift.org/t/cmake-cant-load-the-standard-library-for-swift-on-windows/34605/1 "2020-03-18T05:50:52Z")

</div>

I've tried installing Swift using @compnerd's nightly builds and it installed fine, but when trying to build the examples in [https://github.com/compnerd/swift-build-examples/](https://github.com/compnerd/swift-build-examples), I receive the following:

```
<unknown>:0: error: unable to load standard library for target 'x86_64-unknown-windows-msvc'

```

I tried using the prebuilt installer provided, and I get the same error.

I haven't managed to find anything elsewhere on this, so I posted here.

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [March 18, 2020, 6:04pm UTC](https://forums.swift.org/t/cmake-cant-load-the-standard-library-for-swift-on-windows/34605/2 "2020-03-18T18:04:36Z")

</div>

You should have a look at the documentation at [https://github.com/compnerd/swift-build/blob/master/docs/Windows.md](https://github.com/compnerd/swift-build/blob/master/docs/Windows.md) for details on the flags that are required (`-sdk ...`).

The `-sdk` flags tell the compiler where the platform SDK. The setup on the Windows builds are different so that it is easy to use the toolchain to cross-compile for Android, Windows, and Linux using that toolchain.

---

<div class="post-metadata">

**Author:** ![atirit](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/atirit/32/10884_2.png) [@atirit](https://forums.swift.org/u/atirit)\
**Post date:** [March 20, 2020, 5:37am UTC](https://forums.swift.org/t/cmake-cant-load-the-standard-library-for-swift-on-windows/34605/3 "2020-03-20T05:37:47Z")

</div>

So it turns out doing this at one in the morning isn't the best idea.

I forgot to set the variables listed in the documentation. I didn't execute these lines:

```
SET INSTALLATION_DIR=C:
SET SDK=%INSTALLATION_DIR%\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk
SET OS=windows

```

I ran those before the `cmake` command and now it works.

Thanks!

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [March 20, 2020, 6:24pm UTC](https://forums.swift.org/t/cmake-cant-load-the-standard-library-for-swift-on-windows/34605/4 "2020-03-20T18:24:16Z")

</div>

> [@atirit](#):
>
> I ran those before the `cmake` command and now it works.

Awesome! Glad to hear that you got it working!
