【MSYS2】Windows without MSVC installation MinGW Clang

Main points

  • Windows Installing Clang via MSYS2 Clangd
  • Clang doesn't use MSVC
  • MinGW Clang
  • mingw clang

1. Install MSYS2

  1. Download the MSYS2 installation package, such asmsys2-x86_64-20230318.exe
  2. After the download is completed, select the path to install, such as installing inF:\msys64

2. Install Clang and Clangd

参考Getting Started with Clang and Visual Studio Code on Windows with MSYS2 and MinGW-w64

  1. Importpacman -Syu,Update system
  2. Enter after restartingpacman -S --needed base-devel mingw-w64-ucrt-x86_64-clang mingw-w64-ucrt-x86_64-clang-tools-extraInstallclangandclangd
  3. Add system environment variables, such asF:\msys64\ucrt64\bin
  4. test
clang -v
clang++ -v
clangd -version
clang-format -version

3. Using Clang in VSCode’s CMake project

  1. Restart the system
  2. VSCode opens a folder
  3. ExtensionsInstall
    • Required: C/C++, clangd, CMake, CMake Tools, then Disable < /span>IntelliSence
    • Optional:Clang-Format
  4. Ctrl+Shift+P
  5. CMake: Quick Start, enter a name, such asHelloWorld_Clang
  6. CMake: Scan for Kits
  7. CMake: Select a Kit, selectclang, such as Clang 16.0.0 x86_64-w64-windows-gnu or installed at the release timeClang-cl 16.0.0 x86_64-pc-windows-msvc
  8. NewHelloWorld_Clang.cpp
include <iostream>

int main(int argc, char *argv[])
{
    
    
	cout << "Hello World, Clang!" << endl;
	
	return 0;
}
  1. Click the small start arrow on the bottom toolbar, or run it from the command line
mkdir build

cd build 

cmake ..

./HelloWorld_Clang.exe

Guess you like

Origin blog.csdn.net/weixin_50750441/article/details/129979457