I found the below blog useful : https://developers.redhat.com/blog/2021/04/22/remote-llvm-development-with-visual-studio-code#

This talks about remote SSH setup, but all these things can be easily replicated with native vscode install.

Answer from Darshan Bhat on Stack Overflow
๐ŸŒ
LLVM
llvm.org โ€บ docs โ€บ GettingStartedVS.html
Getting Started with the LLVM System using Microsoft Visual Studio โ€” LLVM 23.0.0git documentation
If you would like to run the LLVM tests you will need Python. Version 3.8 and newer are known to work. You can install Python with Visual Studio 2019, from the Microsoft store or from the Python web site. We recommend the latter since it allows you to adjust installation options. You will need Git for Windows with bash tools, too.
๐ŸŒ
Reddit
reddit.com โ€บ r/vscode โ€บ using llvm with vscode on windows
r/vscode on Reddit: Using LLVM with VSCode on Windows
June 19, 2020 -

Greetings!

I decided to set up VSCode to be able to code in C++ and build my programs using LLVM. So I downloaded official binaries of LLVM 10.0 and installed it on my Windows system, but unfortunately there is no guide on how to make VSCode use LLVM to build projects. Official tutorials suggest using VS C++ compiler or GCC with MinGWx64 and no one seems to be using LLVM on windows for some reason.

I don't want using VS C++ compiler because it will consume too much of my disk space which I don't want to trade and I don't want GCC on MinGW, well, because of MinGW and all the workaround to install it and setup. LLVM seemed to be the easiest option since it has official installer and platform support.

What is the easiest way to setup VSCode for building projects with LLVM on Windows? Or is there a reason to not even try doing so - that'd explain why no one writes guides about that! If it's not recommended to try LLVM for Windows, then what's going to be the best option otherwise? I just want to compile my projects with all the default configurations, I don't care about optimizations and etc. since the projects are just me studying algorithms with C++.

๐ŸŒ
Red Hat
developers.redhat.com โ€บ blog โ€บ 2021 โ€บ 04 โ€บ 22 โ€บ remote-llvm-development-with-visual-studio-code
Remote LLVM development with Visual Studio Code | Red Hat Developer
February 5, 2024 - To run llvm-lit -av current_file from inside VS Code, without using the terminal, you can bring back the command palette with Ctrl+Shift+P and type >launch to open the launch.json file.
๐ŸŒ
Linaro
old.linaro.org โ€บ blog โ€บ how-to-set-up-vs-code-for-llvm-development
How to set up VS Code for LLVM development | Blog | Linaro
The steps described in this document are tested to run on Ubuntu 18.04, however they are equally applicable on any platform that VS Code supports. Download and install the latest version of visual studio code.
๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
LLVM IR Language Support - Visual Studio Marketplace
Extension for Visual Studio Code - LLVM IR language support for Visual Studio Code
๐ŸŒ
GitHub
gist.github.com โ€บ krupkat โ€บ 72a675bfb16244fe887ac77eb2b0fdfa
[VS Code setup] #windows #vscode #clang ยท GitHub
Setup Windows for development in VS Code without installing Visual Studio IDE. Install VS build tools: https://visualstudio.microsoft.com/cs/downloads/#build-tools-for-visual-studio-2022 Install Scoop: https://scoop.sh ... git clone git@github.com:llvm/llvm-project.git git checkout llvmorg-14.0.6 mkdir build cd build cmake-gui ../llvm
Find elsewhere
๐ŸŒ
LLVM Discussion Forums
discourse.llvm.org โ€บ project infrastructure โ€บ llvm dev list archives
Properly configuring vscode for LLVM development - LLVM Dev List Archives - LLVM Discussion Forums
December 1, 2021 - Hi everyone, I am trying to use vscode for cmake development and so far I have been only moderately successful. I think I have most of the things right (including clangd and autocomplete) but I still have a few issues: I am not able to configure vscode + cmake such that the project only rebuilds ...
๐ŸŒ
YouTube
youtube.com โ€บ watch
2023 LLVM Dev Mtg - Starting LLVM Development in Visual Studio on Windows - YouTube
2023 LLVM Developers' Meetinghttps://llvm.org/devmtg/2023-10------Starting LLVM Development in Visual Studio on WindowsSpeaker: Jonathan Smith------Slides: ...
Published ย  December 7, 2023
๐ŸŒ
GitHub
github.com โ€บ microsoft โ€บ vscode-cpptools โ€บ issues โ€บ 6617
Debugging doesn't work with Clang 11 on Windows ยท Issue #6617 ยท microsoft/vscode-cpptools
December 3, 2020 - A clear and concise description of what the bug is: Debugging doesn't work with Clang on Windows due to the file lldb-mi.exe being missing. To Reproduce Please include a code sample and launch.json configuration. Steps to reproduce the behavior: ... { "version": "2.0.0", "tasks": [ { "type": "cppbuild", "label": "Build for debugging", "command": "C:/Program Files/LLVM/bin/clang++.exe", "args": [ "${workspaceFolder}/test.cpp", "-o", "${workspaceFolder}/test.exe", "-g" ], "options": { "cwd": "C:/Program Files/LLVM/bin" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "Build for debugging with Clang++" } ] }
Author ย  microsoft
๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
clangd - Visual Studio Marketplace
Extension for Visual Studio Code - C/C++ completion, navigation, and insights
๐ŸŒ
Solarian Programmer
solarianprogrammer.com โ€บ 2021 โ€บ 06 โ€บ 11 โ€บ install-clang-windows-msys2-mingw-w64
Getting Started with Clang and Visual Studio Code on Windows with MSYS2 and MinGW-w64 | Solarian Programmer
June 11, 2021 - This is a short introduction in getting started with Clang on Windows 10 under MSYS2 and MinGW-w64. The Clang and LLVM binaries from https://llvm.org/ require that you to have Visual Studio 2019 installed on your machine, MSYS2 is a lighter alternative.
๐ŸŒ
GitHub
github.com โ€บ sunxfancy โ€บ vscode-llvm
GitHub - sunxfancy/vscode-llvm: VSCode LLVM Compiler Explorer ยท GitHub
Download from VSCode marketplace. This is a tool for compiler developers of LLVM.
Starred by 234 users
Forked by 5 users
Languages ย  TypeScript 91.8% | JavaScript 5.6% | CSS 2.6%
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ cpp โ€บ build โ€บ clang-support-msbuild
Clang/LLVM support in Visual Studio projects | Microsoft Learn
For more information, see Set a custom LLVM location. For Linux projects, Visual Studio uses the Clang GCC-compatible frontend. The project properties and nearly all compiler flags are identical ยท To configure a Visual Studio Linux project to use Clang: Right-click on the project node in Solution Explorer and choose Properties. Typically, you should first choose All configurations at the top of the dialog. Under General > Platform Toolset, choose Clang for Windows Subsystem for Linux if you're using Windows Subsystem for Linux (WSL).
Top answer
1 of 3
21

On Windows, Clang is not self-sufficient, and is supposed to be used in combination with an other compiler: either MinGW (GCC) or MSVC. Clang is going to use the standard library (and other libraries/headers) of that compiler, since it doesn't ship with ones of its own.

If you want to use it with MSVC and have it installed, running clang-cl instead of cl should just work.

But since you mentioned VSC, I assume you don't want MSVC. Then...

If you want to use it with MinGW and have it installed, use clang --target=x86_64-w64-windows-gnu instead of gcc, and it should also just work. (That's assuming your MinGW produces 64-bit apps. Replace x86_64 with i686 if it's 32-bit.)

If you don't have MinGW yet, you can get a fresh version from MSYS2. Then you have an option to install their unofficial build of Clang instead of the regular one, which has an advantage of using --target=x86_64-w64-windows-gnu automatically (so you don't have to write it manually).

2 of 3
13
  1. Install Clang using Visual Studio Installer.
    (1) Open 'Visual Studio Installer'.
    (2) Visual Studio Community 2022 -> click 'Modify'
    (3) In the [Installation details] checkbox list, check 'C++ Clang tools for Windows'
    (4) Install.

  2. Add clang.exe (created by the above procedure) to the Path environment variable.

  3. Now try clang --version in the terminal.

Great, you're good to go :)


Edit: If you didn't change the default installation path, clang.exe should likely be in C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm such as (for x64) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\bin.

๐ŸŒ
FreeBSD
forums.freebsd.org โ€บ development โ€บ userland programming and scripting
C - Solved - How to use or set Clang/LLVM/GCC compilers on VS Code? | The FreeBSD Forums
August 26, 2022 - Its just that I cannot compile/build simple "C" code to use clang/llvm on VS Code by default when clicking on the "play button" which is located at the top right on VS Code. Thanks for any advice. EDIT: I spent about 2 full days in figuring out how to get VS code to work as an IDE for c/c++ on FreeBSD 13.1 I am now able to compile OpenCV 4 projects using clang and debug using GDB on VS Code.