# How to use Clang on Windows ?

**URL:** <https://forums.unrealengine.com/t/how-to-use-clang-on-windows/1990085>\
**Category:** C++\
**Tags:** c-c, c-class-wizard, c-and-bluepri, c-custommeshcomponen, c-and-blueprint, c-error, c-class, c-custom-shape, c-programming, c-cone-shape, unreal-engine, CPP, question\
**Created:** [August 24, 2024, 1:02pm UTC](https://forums.unrealengine.com/t/how-to-use-clang-on-windows/1990085 "2024-08-24T13:02:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davidutz-01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Davidutz-01](https://forums.unrealengine.com/u/Davidutz-01)\
**Post date:** [August 24, 2024, 1:02pm UTC](https://forums.unrealengine.com/t/how-to-use-clang-on-windows/1990085/1 "2024-08-24T13:02:10Z")

</div>

Hello everyone !

I was wondering if someone know how to setup Clang on Windows for compiling instead of MSVC.  
I’m using the “Build From Source” Unreal Engine 5.3 version (git) and tried several things to make this work but no one works for me.

I installed Clang using both Chocolatey package and Visual Studio Installer.

Things I tried tried:

- Adding`<WindowsPlatform> <!-- Build using Clang instead of Visual Studio 2017 --> <Compiler>Clang</Compiler> </WindowsPlatform>` inside UnrealBuildTool/BuildConfiguration.xml. Throwing an error like `warning: The element 'BuildConfiguration' in namespace 'https://www.unrealengine.com/BuildConfiguration' has invalid child element 'Compiler' in namespace 'https://www.unrealengine.com/BuildConfiguration'.`

- Forcing using Clang compiler inside my UnrealProject.Target.cs (TargetRules) with this line ` // Force Clang compiler WindowsPlatform.Compiler = WindowsCompiler.Clang;`  
Not working as well and throwing an error : `Unable to find valid 14.39.33519 C++ toolchain for Clang x64`

It’s an common issue on Windows version of Unreal Engine ? This seems to work on MacOS and Linux so why not Windows ?

Thanks for everyone who read !

---

<div class="post-metadata">

**Author:** ![AK\_Ahmmad](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AK\_Ahmmad](https://forums.unrealengine.com/u/AK_Ahmmad)\
**Post date:** [September 8, 2024, 8:54am UTC](https://forums.unrealengine.com/t/how-to-use-clang-on-windows/1990085/2 "2024-09-08T08:54:01Z")

</div>

I am on the same boat, but I am using binary build instead of source code.

I have successfully made Clang work on Windows, using Clang as the compiler and MSVC as the toolchain. I did not try to use MinGW GCC toolchain because Epic Games did not build against it on Windows, I don’t know if it is recommended.

# **†**  **Clang compiler only:**

This is my BuildConfiguration.xml:

```auto
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
    <WindowsPlatform>
        <Compiler>Clang</Compiler>
        <CompilerVersion>Latest</CompilerVersion>
        <Toolchain>VisualStudio2022</Toolchain>
        <ToolchainVersion>14.34.31933</ToolchainVersion>
    </WindowsPlatform>
    <ProjectFileGenerator>
        <Format>VisualStudioCode</Format>
    </ProjectFileGenerator>
</Configuration>

```

The last part `<ProjectFileGenerator>` is not necessary, it just makes `UnrealBuildTool` run `-Mode=VSCode` when you click “Generate Visual Studio project files” from the context menu on your `.uproject` in Explorer.

There are 3 XML files in 3 different directories (each serve a purpose) to choose from to setup Clang as the compiler in BuildConfiguration.xml:

- %appdata%\Unreal Engine\UnrealBuildTool\
- YourProjectDirectory\Saved\UnrealBuildTool\
- %username%\Documents\Unreal Engine\Saved\UnrealBuildTool\ (This one is unique to source builds, it does not exist for binary UE – also not sure if the directory is correct)

**†** The correct Clang version must be installed to avoid compiling issues/errors. Check your Unreal Engine version, and follow the documentation in the link below and change the version of UE in the page (on the left side) according to your UE version. (the link is set to open to the latest version)

**Documentation:** [Use Clang to Build Microsoft Platforms in Unreal Engine | Unreal Engine 5.7 Documentation | Epic Developer Community](https://dev.epicgames.com/documentation/en-us/unreal-engine/use-clang-to-build-microsoft-platforms-in-unreal-engine)

* * *

# **†**  **Clangd:** _(Clang intellisense engine)_

After that, you need to run `-Mode=GenerateClangDatabase` in CMD using UnrealBuildTool.exe to make clangd work.  
**Directory:** C:\Program Files\Epic Games\UE\_5.3\Engine\Binaries\DotNET\UnrealBuildTool

**†** This generates the necessary compile\_commands.json

**clangd:** [https://clangd.llvm.org/](https://clangd.llvm.org/)  
**clangd installation:** [Getting started](https://clangd.llvm.org/installation)

**A thread on UE forums of many users trying to make clangd work:** [Get compile\_commands.json](https://forums.unrealengine.com/t/get-compile-commands-json/433389/)

@dzemzmcdonalda found out that `-Mode=GenerateClangDatabase` is not incremental: [UBT GenerateClangDatabase is NOT incremental and recreates whole compile\_commands.json each time](https://forums.unrealengine.com/t/ubt-generateclangdatabase-is-not-incremental-and-recreates-whole-compile-commands-json-each-time/2005308)

**Assuming you want to use VS Code with clangd:** [https://www.youtube.com/watch?v=JxfNn5DYG\_o](https://www.youtube.com/watch?v=JxfNn5DYG_o)

At this point, it just takes too much time to setup and maintain. I just reverted back to MSVC. I wish I can continue down with LLVM road, but it is not intuitive.

Let me know what happens, I am still interested in it.

If only Epic Games can make a complete guide on how to correctly setup and use Clang on all platforms, since I believe they use Clang themselves. And if it is possible to use Clang on Windows without MSVC toolchain.

* * *

**†**  **NOTE:** To compile your project with Clang only, you don’t have to follow the Clangd steps.

**†** Since this is the first result on search engines, further clarifications were added.

**†** _2025 edits marked by dagger symbol._

---

<div class="post-metadata">

**Author:** ![Robomoo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Robomoo](https://forums.unrealengine.com/u/Robomoo)\
**Post date:** [October 13, 2024, 10:01pm UTC](https://forums.unrealengine.com/t/how-to-use-clang-on-windows/1990085/3 "2024-10-13T22:01:42Z")

</div>

Your post is very helpful; I successfully built UE 5.3.0 with Clang using the same settings as you, however the program always hangs on startup at around 90%, when it starts asynchronous asset loading, unless I disable multithreading.

Did you also encounter this issue when building with Clang? If not, could you share what Clang version and Windows SDK version you’re using? Thanks very much.

---

<div class="post-metadata">

**Author:** ![AK\_Ahmmad](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AK\_Ahmmad](https://forums.unrealengine.com/u/AK_Ahmmad)\
**Post date:** [October 14, 2024, 12:10am UTC](https://forums.unrealengine.com/t/how-to-use-clang-on-windows/1990085/4 "2024-10-14T00:10:48Z")

</div>

You are welcome, I am glad you found my post helpful.

Unfortunately, I _did not_ build UE from source, I download the binary build from Epic Games Launcher and use Clang to build my C++ source code, not the engine.

For every UE version you would like to use, you should check the release notes of that version and scroll down to [Platform SDK Upgrades](https://dev.epicgames.com/documentation/en-us/unreal-engine/unreal-engine-5.3-release-notes#platformsdkupgrades) section and check what Epic Games recommend for each version. (Ctrl+F in browser, type “farm” to get there quickly)

In your case for Unreal Engine 5.3:

- Visual Studio 2022 v17.4 or newer
- Windows SDK 10.0.18362 or newer
- LLVM clang 14.0.1
- .NET 4.6.2 Targeting Pack
- .NET 6.0

IDE Version the Build farm compiles against

- Visual Studio: Visual Studio 2022 17.4 14.34.31933 toolchain and Windows 10 SDK (10.0.18362.0)

Some people reported that setting `<CompilerVersion>` in BuildConfiguration.xml to `Latest` instead of manually typing your version e.g. `14.0.1`; is necessary or it might have problems or something I can’t remember (experiment to check it out, I don’t have links or source to prove that). So having 1 LLVM installation might be the way to go. Also make sure it is installed in **C:\Program Files\LLVM** and it is added to PATH, I guess UE expects LLVM to be at its default directory.

Finally, from my last post, the BuildConfiguration.xml shown _was_ the configuration I had set to build with Clang before I left back for MSVC.

```auto
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
    <WindowsPlatform>
        <Compiler>Clang</Compiler>
        <CompilerVersion>Latest</CompilerVersion>
        <Toolchain>VisualStudio2022</Toolchain>
        <ToolchainVersion>14.34.31933</ToolchainVersion>
    </WindowsPlatform>
    <ProjectFileGenerator>
        <Format>VisualStudioCode</Format>
    </ProjectFileGenerator>
</Configuration>

```

Good luck!

---

<div class="post-metadata">

**Author:** ![Robomoo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Robomoo](https://forums.unrealengine.com/u/Robomoo)\
**Post date:** [October 15, 2024, 5:11pm UTC](https://forums.unrealengine.com/t/how-to-use-clang-on-windows/1990085/5 "2024-10-15T17:11:25Z")

</div>

Ah perfect, I just had the wrong version of Clang. Switching to 14.0.1 fixed it. I saw [here](https://dev.epicgames.com/documentation/en-us/unreal-engine/use-clang-to-build-microsoft-platforms-in-unreal-engine) that up to Clang 16.0.0 is supported, but that must be in newer versions; I should have checked the version release notes.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![AK\_Ahmmad](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AK\_Ahmmad](https://forums.unrealengine.com/u/AK_Ahmmad)\
**Post date:** [October 16, 2024, 1:21pm UTC](https://forums.unrealengine.com/t/how-to-use-clang-on-windows/1990085/6 "2024-10-16T13:21:45Z")

</div>

You are welcome!
