0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RubyをWindows上でVisual C++でビルドする2025

Last updated at Posted at 2025-08-29

参考

2024年版から特に変更点はない。

Visual Studio

サポートバージョン

2025/08時点では、2015以降のVisual Studioのリリースは以下の4つあり、Visual Studio 2022が最新版である。

  • Visual Studio 2015 (EOL: 2025/10/14)
  • Visual Studio 2017 (EOL: 2027/04/13)
  • Visual Studio 2019 (EOL: 2029/04/10)
  • Visual Studio 2022 (EOL: 2032/01/13)

インストール

  1. Visual Studio 2022 > Community > Free download からダウンロード
  2. VisualStudioSetup.exe を起動し、Continue を押す
  3. インストール対象を選択する
    • Workloads
      • Desktop development with C++ (optional, ↓の一部を選んでくれる)
    • Individual Components
      • Code tools
        • vcpkg package manager
      • Compilers, build tools, and runtimes
        • Windows Universal CRT SDK
        • C++/CLI support for v143 build tools (Latest)
        • MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
      • SDKs, libraries, and frameworks
        • Windows 11 SDK (10.0.26100.4654)
    • Language packs
      • English
  4. Install, Continue を押す

起動

  • Start > Search: Native > x64 Native Tools Command Prompt for VS 2022

clnmake が動けばOK。

scoop

  • Start > Search: Power > Windows PowerShell

Quickstartにある通り、以下のスクリプトをPowerShellで実行する。

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

x64 Native Tools Command Prompt for VS 2022 を起動し直すと、scoopが使えるようになる。

git, ruby

x64 Native Tools Command Prompt for VS 2022 (素のcmd.exeやPowerShellでも多分OK) で以下を実行する。

scoop install git ruby

x64 Native Tools Command Prompt for VS 2022 を起動し直すと、gitとrubyが使えるようになる。

セットアップ

x64 Native Tools Command Prompt for VS 2022 で以下を実行する。

git clone https://github.com/ruby/ruby
cd ruby

# vcpkg.json に書いてある依存をインストール
vcpkg install --triplet=x64-windows

ビルド

# vcpkg_installed\x64-windows へのパスを合わせてconfigure
win32\configure.bat --without-ext=+,syslog --with-opt-dir=C:\Users\k0kubun\src\github.com\ruby\ruby\vcpkg_installed\x64-windows

# DLLをビルドディレクトリにsymlinkする。かわりに vcpkg_installed\x64-windows\bin をPATHの先頭に追加してもよい
nmake prepare-vcpkg

# ビルド
nmake

これでRubyがビルドされ、 nmake test-all などが実行できるようになる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?