はじめに
Atcoderでは、言語アップデート(2023年版)が予定されています。
乗るしかない、このビッグウェーブに
Crystal
TLEに悩むRubistの涙ぐましい努力もございますが、
Windows上でCrystalの実行及び確認ができると助かります。
Crystal の インストール
詳細は上記記事を参照していただきたいのですが、VisualStudioのインストールはどれをどうインストールするのか面倒。
ちなみに、VisualStudioのインストールなしで実行すると
> crystal -v
Crystal 1.7.2 [29f9ac5] (2023-01-23)
LLVM: 13.0.1
Default target: x86_64-pc-windows-msvc
> crystal .\main.cr
Error: Could not execute linker: `cl.exe`: File not found
Run with `--verbose` to print the full linker command.
cl.exeが無いって怒られます。
cl.exe とは
cl.exe は、Microsoft C++ (MSVC) C および C++ コンパイラとリンカーを制御するツールです。
Scoop で Visual Studio Build Tools 2022 のインストール
面倒に思う人が沢山いたのだと思われますが、VisualStudioBuildTools用のパッケージが用意されていました。
scoop install vs_2022_cpp_build_tools
コマンドを実行すると、インストーラがダウンロードされてインストールが実行されます。

但し、インストール先は、scoopフォルダ内ではなく、C:\Program Files (x86)\Microsoft Visual Studioとなりました。
Checking hash of vs_BuildTools.exe ... ok.
Running installer... error.
ERROR Exit code was 3010!
Installation aborted. You might need to run 'scoop uninstall vs_2022_cpp_build_tools' before trying again.
エラー3010が発生しますが、再起動すれば大丈夫です。
If you don't already have the correct Visual Studio components discussed earlier, run scoop install vs_2022_cpp_build_tools. The Visual Studio Installer UI will open to display progress. If you see ERROR Exit code was 3010!, this simply means you need to reboot. Run the same command again and reboot.
Hello Crystal
> crystal .\main.cr
ライブラリ crystal-run-main.tmp.lib とオブジェクト crystal-run-main.tmp.exp を作成中
Hello Crystal
c/c++系 での利用
cl.exeがあるということは、C/C++系の言語を使用できますので、競プロにとって有効と思われます。
まとめ
- scoop による Crystal の環境構築に成功した