3 Ruby supports a few native build platforms for Windows.
5 * mswin: Build using Microsoft Visual C++ compiler with vcruntimeXXX.dll
6 * mingw-msvcrt: Build using compiler for Mingw with msvcrtXX.dll
7 * mingw-ucrt: Build using compiler for Mingw with Windows Universal CRT
9 ## Building Ruby using Mingw with UCRT
11 The easiest build environment is just a standard [RubyInstaller-Devkit]
12 installation and [git-for-windows]. You might like to use [VSCode] as an
17 Ruby core development can be done either in Windows `cmd` like:
22 pacman -S --needed %MINGW_PACKAGE_PREFIX%-openssl %MINGW_PACKAGE_PREFIX%-libyaml %MINGW_PACKAGE_PREFIX%-libffi
27 git clone https://github.com/ruby/ruby
31 sh configure -C --disable-install-doc
35 or in MSYS2 `bash` like:
41 pacman -S --needed $MINGW_PACKAGE_PREFIX-openssl $MINGW_PACKAGE_PREFIX-libyaml $MINGW_PACKAGE_PREFIX-libffi
46 git clone https://github.com/ruby/ruby
50 ./configure -C --disable-install-doc
54 [RubyInstaller-Devkit]: https://rubyinstaller.org/
55 [git-for-windows]: https://gitforwindows.org/
56 [VSCode]: https://code.visualstudio.com/
58 ## Building Ruby using Visual C++
62 1. Windows 10/Windows Server 2016 or later.
64 2. Visual C++ 14.0 (2015) or later.
66 **Note** if you want to build x64 version, use native compiler for
69 3. Please set environment variable `INCLUDE`, `LIB`, `PATH`
70 to run required commands properly from the command line.
72 **Note** building ruby requires following commands.
80 4. If you want to build from GIT source, following commands are required.
86 You can use [scoop](https://scoop.sh/) to install them like:
89 scoop install git patch sed ruby
92 5. You need to install required libraries using [vcpkg](https://vcpkg.io/) on
93 directory of ruby repository like:
96 vcpkg --triplet x64-windows install
99 6. Enable Command Extension of your command line. It's the default behavior
100 of `cmd.exe`. If you want to enable it explicitly, run `cmd.exe` with
103 ### How to compile and install
105 1. Execute `win32\configure.bat` on your build directory.
106 You can specify the target platform as an argument.
107 For example, run `configure --target=i686-mswin32`
108 You can also specify the install directory.
109 For example, run `configure --prefix=<install_directory>`
110 Default of the install directory is `/usr` .
111 The default _PLATFORM_ is `i386-mswin32_`_MSRTVERSION_ on 32-bit
112 platforms, or `x64-mswin64_`_MSRTVERSION_ on x64 platforms.
113 _MSRTVERSION_ is the 2- or 3-digits version of the Microsoft
116 2. Change _RUBY_INSTALL_NAME_ and _RUBY_SO_NAME_ in `Makefile`
117 if you want to change the name of the executable files.
118 And add _RUBYW_INSTALL_NAME_ to change the name of the
119 executable without console window if also you want.
121 3. You need specify vcpkg directory to use `--with-opt-dir`
122 option like `win32\configure.bat --with-opt-dir=vcpkg_installed\x64-windows`
124 4. Run `nmake up` if you are building from GIT source.
128 6. Run `nmake prepare-vcpkg` if you need to copy
129 vcpkg installed libraries like `libssl-3-x64.dll` to the build directory.
133 8. Run `nmake install`
137 * Build on the ruby source directory.
140 ruby source directory: C:\ruby
141 build directory: C:\ruby
142 install directory: C:\usr\local
148 win32\configure --prefix=/usr/local
154 * Build on the relative directory from the ruby source directory.
157 ruby source directory: C:\ruby
158 build directory: C:\ruby\mswin32
159 install directory: C:\usr\local
167 ..\win32\configure --prefix=/usr/local
173 * Build on the different drive.
176 ruby source directory: C:\src\ruby
177 build directory: D:\build\ruby
178 install directory: C:\usr\local
184 C:\src\ruby\win32\configure --prefix=/usr/local
187 nmake install DESTDIR=C:
190 * Build x64 version (requires native x64 VC++ compiler)
193 ruby source directory: C:\ruby
194 build directory: C:\ruby
195 install directory: C:\usr\local
201 win32\configure --prefix=/usr/local --target=x64-mswin64
209 You can **NOT** use a path name that contains any white space characters
210 as the ruby source directory, this restriction comes from the behavior
211 of `!INCLUDE` directives of `NMAKE`.
213 You can build ruby in any directory including the source directory,
214 except `win32` directory in the source directory.
215 This is restriction originating in the path search method of `NMAKE`.
217 ### Dependency management
219 Ruby uses [vcpkg](https://vcpkg.io/) to manage dependencies on mswin platform.
221 You can update and install it under the build directory like:
224 nmake update-vcpkg # Update baseline version of vcpkg
225 nmake install-vcpkg # Install vcpkg from build directory
231 Any icon files(`*.ico`) in the build directory, directories specified with
232 _icondirs_ make variable and `win32` directory under the ruby
233 source directory will be included in DLL or executable files, according
235 $(RUBY_INSTALL_NAME).ico or ruby.ico --> $(RUBY_INSTALL_NAME).exe
236 $(RUBYW_INSTALL_NAME).ico or rubyw.ico --> $(RUBYW_INSTALL_NAME).exe
237 the others --> $(RUBY_SO_NAME).dll
239 Although no icons are distributed with the ruby source, you can use
240 anything you like. You will be able to find many images by search engines.
241 For example, followings are made from [Ruby logo kit]:
243 * Small [favicon] in the official site
245 * [vit-ruby.ico] or [icon itself]
247 [Ruby logo kit]: https://cache.ruby-lang.org/pub/misc/logo/ruby-logo-kit.zip
248 [favicon]: https://www.ruby-lang.org/favicon.ico
249 [vit-ruby.ico]: http://ruby.morphball.net/vit-ruby-ico_en.html
250 [icon itself]: http://ruby.morphball.net/icon/vit-ruby.ico