Main points
- Windows Installing Clang via MSYS2 Clangd
- Clang doesn't use MSVC
- MinGW Clang
- mingw clang
1. Install MSYS2
- Download the MSYS2 installation package, such asmsys2-x86_64-20230318.exe
- After the download is completed, select the path to install, such as installing in
F:\msys64
2. Install Clang and Clangd
参考Getting Started with Clang and Visual Studio Code on Windows with MSYS2 and MinGW-w64
- Import
pacman -Syu
,Update system - Enter after restarting
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-clang mingw-w64-ucrt-x86_64-clang-tools-extra
Installclang
andclangd
- Add system environment variables, such as
F:\msys64\ucrt64\bin
- test
clang -v
clang++ -v
clangd -version
clang-format -version
3. Using Clang in VSCode’s CMake project
- Restart the system
- VSCode opens a folder
Extensions
Install- Required:
C/C++
,clangd
,CMake
,CMake Tools
, then Disable < /span>IntelliSence
- Optional:
Clang-Format
- Required:
Ctrl+Shift+P
CMake: Quick Start
, enter a name, such asHelloWorld_Clang
CMake: Scan for Kits
CMake: Select a Kit
, selectclang
, such asClang 16.0.0 x86_64-w64-windows-gnu
or installed at the release timeClang-cl 16.0.0 x86_64-pc-windows-msvc
- New
HelloWorld_Clang.cpp
include <iostream>
int main(int argc, char *argv[])
{
cout << "Hello World, Clang!" << endl;
return 0;
}
- Click the small start arrow on the bottom toolbar, or run it from the command line
mkdir build
cd build
cmake ..
./HelloWorld_Clang.exe