Skip to content

Instantly share code, notes, and snippets.

@scivision
Last active June 27, 2026 00:43
Show Gist options
  • Select an option

  • Save scivision/3e46369ad64aca962ab8c4199af73cc3 to your computer and use it in GitHub Desktop.

Select an option

Save scivision/3e46369ad64aca962ab8c4199af73cc3 to your computer and use it in GitHub Desktop.
GCC/Gfortran or Clang/Flang PowerShell source scripts for Windows

PowerShell source scripts for GCC/Gfortran or Clang/Flang

Use from Windows Powershell like:

. clang_arm.ps1

or

. gcc_ucrt.ps1
$r="$Env:SystemDrive/msys64"
# The MSYS2 root directory is where MSYS2 is installed. It's CPU architecture dependent.
# for ARM64 CPU:
$r="$r/clangarm64"
$b="$r/bin"
$Env:CC="$b/clang.exe"
$Env:CXX="$b/clang++.exe"
$Env:FC="$b/flang.exe"
$Env:AR="$b/llvm-ar.exe"
# important to put UCRT first to avoid "collect2.exe: error: ld returned 116 exit status" and DLL Hell
$Env:Path = "$b;$Env:Path"
$Env:CMAKE_PREFIX_PATH="$r"
$r="$Env:SystemDrive/msys64"
# The MSYS2 root directory is where MSYS2 is installed. It's CPU architecture dependent.
# for x86_64 CPU:
$r="$r/ucrt64"
$b="$r/bin"
$Env:CC="$b/gcc.exe"
$Env:FC="$b/gfortran.exe"
$Env:CXX="$b/g++.exe"
# important to put UCRT first to avoid "collect2.exe: error: ld returned 116 exit status" and DLL Hell
$Env:Path = "$b;$Env:Path"
$Env:CMAKE_PREFIX_PATH="$r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment