param( [string]$Opt = "-O0" ) $ErrorActionPreference = "Stop" # Compile hello.cpp as a shared library (also generates libhello.lib import library) clang++ -std=c++17 $Opt -shared -o libhello.dll hello.cpp "-Wl,/IMPLIB:libhello.lib" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # Compile and link main.cpp with the shared library clang++ -std=c++17 $Opt -o main.exe main.cpp libhello.lib if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host "Build successful"