VSCode 配置C++环境(LLVM/Clang)/ XCPC刷题环境CodeRunner

编译器选择

一般gcc和Clang选,gcc可以直接下MinGW,clang可以直接LLVM都是包含的,这里选择Clang,似乎编译速度比较快,适合我这种ap(acm批)调bug的时候快速编译比较爽。

下载(github)

windows可以选择clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz。也可以选择LLVM-18.1.8-win64.exe(编译好的二级制文件直接安装全部LLVM)推荐后者。

以及MinGWx86_64-14.2.0-release-win32-seh-msvcrt-rt_v12-rev0.7z Clang没有头文件要配合MinGw

添加环境变量。(如果系统本来环境很乱可能添加不了需要手动)

手动配置环境

以LLVM安装在 C:\Program Files\LLVM 为例,环境变量path里面添加 C:\Program Files\LLVM\bin

如果cmd 窗口中 输入clang -v 正常即可 系统环境变量配置完成

VSCode配置

系统配好了可能vscode还是不能,比如cmd中可以clang -v,vsc中的terminal确不行。

ctrl+,设置搜索terminal.integrated.env.windows”(Windows 系统),”terminal.integrated.env.osx”(Mac 系统),或 “terminal.integrated.env.linux”(Linux 系统)。修改json。

{
    "terminal.integrated.env.windows": {
        "PATH": "C:\\Program Files\\LLVM\\bin;${env:PATH}"
    }
}

XCPC配置

比赛环境一般为Ubuntu+gcc,vscode的插件一般只支持code runner。偶尔支持cph(平时可用)

gcc运行指令:

Windows

  • 编译不指定 C++ 标准:powershell复制代码g++ 1.cpp -o 1.exe
  • 编译并指定 C++23 标准:powershell复制代码g++ 1.cpp -std=c++23 -o 1.exe
  • 运行生成的可执行文件:powershell复制代码.\1.exe

Linux

  • 编译不指定 C++ 标准:bash复制代码g++ 1.cpp -o 1.out && .\1.out
  • 编译并指定 C++23 标准:bash复制代码g++ 1.cpp -std=c++23 -o 1.out && .\1.out

clang运行指令

Windows

  • 编译不指定 C++ 标准:powershell复制代码clang++ 1.cpp -o 1.exe
  • 编译并指定 C++23 标准:powershell复制代码clang++ 1.cpp -std=c++23 -o 1.exe
  • 运行生成的可执行文件:powershell复制代码.\1.exe

Linux

  • 编译不指定 C++ 标准:bash复制代码clang++ 1.cpp -o 1.out && ./1.out
  • 编译并指定 C++23 标准:bash复制代码clang++ 1.cpp -std=c++23 -o 1.out && ./1.out

clang缺少头文件

需要借助MinGw

clang++  1.cpp -o 1.exe --target=x86_64-w64-mingw32 --sysroot="C:\Program Files\mingw64"

可以直接在code runner里修改 json “code-runner.executorMap”

修改默认

"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt" 

为你想要的

"cpp": "cd $dir && g++ -std=c++23 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",

或者clang的(就不用修改环境变量)

"cpp": "cd $dir && clang++ $fileName -o $fileNameWithoutExt --target=x86_64-w64-mingw32 --sysroot=\"C:/Program Files/mingw64\" && $dir$fileNameWithoutExt",

评论

  1. 1 年前
    2024-12-31 19:43:14

    akustik su kaçak tespiti Pendik’teki evimizde yaşadığımız su kaçağı tespiti sorunu kısa sürede çözüldü. https://ideasofdecoration.com/index.php/author/kacak/

  2. 1 月前
    2025-12-10 10:38:34

    Just had a brilliant time placing a few bets on W88 through w88ngo! Really user-friendly site, and I even managed to snag a cheeky win. Definitely giving it a thumbs up. Check it out here: w88ngo

  3. 1 月前
    2025-12-19 0:58:01

    Hey there! So, I had a play at fun88za the other day. Not too shabby at all. The games are alright and the site’s pretty user-friendly. Have a squiz: fun88za

  4. 3 周前
    2025-12-27 21:42:48

    Need a quick fix? PCSObetlogin. Gets you straight to the action. Easy login and decent selection of games. No complaints from me! Quick and painless! pcsobetlogin keepin’ it simple.

  5. 22 小时前
    2026-1-17 4:30:27

    Milagro777 is where the real winnings are hiding! I mean, I’ve had some amazing runs here. The layout’s straightforward, which is a plus. Give it a shot! milagro777

  6. 22 小时前
    2026-1-17 4:30:44

    Yo, heard about utcuong368 and decided to give it a whirl. Not bad at all! Good selection of games and the bonuses seem alright. Might stick around for a bit. Give it a shot! utcuong368

  7. 22 小时前
    2026-1-17 4:31:00

    Just tried winomxcasino, and I’m impressed. Solid casino with a cool vibe. I especially enjoyed the live dealer games. Give winomxcasino a try, you know you want to! winomxcasino

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇