Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to install clang on windows using the visual studio build tools

Clang on Windows (VS 2017 build tools)

There are plenty of tutorials online on how to install clang on windows with visual studioIDE and MinGW. However, there are none on clang with visual studio build tools.

Requirements:

  • 64-bit Windows 7 SP1 or newer with the latest updates installed
  • 6 GB of free space on the partition where Windows is installed
  • internet connection (for installation only)

1. Install VS 2017 build tools

%VS2017BuildToolsDir% = installation directory of VS 2017 build tools

  1. download and run the microsoft visual studio build tools
  2. select and install the following individual component(s):
  • Static analysis tools
  • VC++ 2015.3 v140 toolset for desktop (x86,x64)
  • VC++ 2017 v141 toolset (x86,x64)
  • Visual C++ Build Tools core features
  • Windows Universal C Runtime
  • if windows 10:
    • Windows 10 SDK (10.0.10240.0)
  • if windows 7 / 8 / 8.1
    • Windows Universal CRT SDK
    • Windows 8.1 SDK
  1. Start > Visual Studio 2017 > Developer Command Prompt for VS 2017 (run as administrator)
  2. execute command(s):
cd %VS2017BuildToolsDir%\Common7\Tools\
VsMSBuildCmd

2. Install LLVM

  1. download and run LLVM
  2. add to PATH for current/all user(s)

3. Remove redulant files

  1. run visual studio installer
  2. remove the following individual component(s):
  • VC++ 2015.3 v140 toolset for desktop (x86,x64)

4. Test LLVM

%procdir% = directory where you created proc.c

  1. create proc.c with
#include <stdio.h>

int main(void) {
    printf("Test\n");
    while(1) {}
    return 0;
}
  1. Start > Windows System > Command Prompt (run as administrator)
  2. execute command(s):
cd %ProcDir% 
clang -std=c89 proc.c -o proc.exe
proc.exe

Troubleshoot

'clang' is not recognized as an internal or external command, operable program or batch file.

You didn't select the set PATH for current/all user(s). If you did but it still didn't work, set the path environment variable manually by adding %LLVMInstallLocation%\bin

clang.exe: warning: unable to find a Visual Studio installation; try running Clang from a developer command prompt [-Wmsvc-not-found]

You didn't install VC++ 2015.3 v140 toolset for desktop (x86,x64) and/or VC++ 2017 v141 toolset and/or run VsMSBuildCmd

@CapitanFuture

This comment has been minimized.

Copy link

CapitanFuture commented Oct 7, 2018

Very helpful instruction for me !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.