0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WineでDXRubyを動かす(Ubuntu 24.04)

0
Last updated at Posted at 2026-03-01

簡単な確認用スクリプトで試した程度ですが、動きました。手順をメモしておきます。

バージョン

Ubuntu Linux 24.04
Wine 9.0~repack-4build3
Ruby 3.0.4 (i386-mingw32)
DXRuby 1.4.7

手順

Wine 関連のインストールなど:

sudo apt install wine winetricks

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install wine32:i386

wineboot
winetricks d3dx9
winetricks cjkfonts # デフォルトフォントで日本語を使いたい場合は必要

Ruby ランタイムの用意:

  # 作業ディレクトリに移動(適宜読み替えてください)
cd /vagrant_data

  # RubyInstaller からアーカイブをダウンロード
wget https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.0.4-1/rubyinstaller-3.0.4-1-x86.7z
  # 展開
7z x rubyinstaller-3.0.4-1-x86.7z

※ URL は RubyInstaller の Download Archives のページに載っているもの。

この時点で以下のような配置になる:

/ ... Wine 側では Z:/ に対応
  vagrant_data/
    rubyinstaller-3.0.4-1-x86/
      bin/
        ruby.exe
        ...

DXRuby のインストール:

WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/bin \
  wine gem install dxruby

適当に用意した動作確認用スクリプト:

require "dxruby"

Window.width = 320
Window.height = 240

snd = Sound.new("sound_2ch.wav")
se = SoundEffect.new(500) { [440, 10] }

ball_x = 0

Window.loop do
  snd.play if Input.key_push?(K_1)
  se.play if Input.key_push?(K_2)

  ball_x += 1
  ball_x = 0 if Window.width < ball_x

  Window.draw_line(0, 0, 320, 240, C_GREEN)
  Window.draw_circle_fill(ball_x, 150, 50, [150, 255, 255, 0])
  Window.draw_font(5, 5, "test\nあいうえお漢字", Font.default)
end

実行:

WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/bin \
  wine ruby sample.rb

image.png

基本的な図形描画、フォント描画、音の再生が確認できました。

メモ

dxruby64 も動いた

dxruby64 は DXRuby のフォークで、 Ruby 3.1 以降に対応しています(参考: DXRubyの64bit対応版|rbCanvas)。Ruby 3.4.8(64bit版)で動かせました。

unexpected ucrtbase.dll というエラーが出る → winetricks ucrtbase2019 で解消しました。

作業メモ

以下、作業途中のエラー対応なども含むメモです。

クリーンな環境で確認するため Vagrant + VirtualBox で作業しました。


まずは最低限必要そうなものだけインストールして ~/.wine を初期化。

sudo apt install wine winetricks
wineboot

Ruby ランタイムの用意。

  • DXRuby 1.4.7 がサポートしているのは Ruby 3.0 まで
  • Ruby 3.0 系では 3.0.6 が最新

なので 3.0.6 で試してみる。

  $ WINEPATH="Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/bin" \
  wine ruby.exe sample.rb

it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first.  as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32:i386"
wine: created the configuration directory '/home/vagrant/.wine'
004c:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80004002
004c:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, hr 0x80004002
004c:err:ole:apartment_get_local_server_stream Failed: 0x80004002
0054:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80004002
0054:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, hr 0x80004002
0054:err:ole:apartment_get_local_server_stream Failed: 0x80004002
0054:err:ole:start_rpcss Failed to open RpcSs service
wine: failed to open L"C:\\windows\\syswow64\\rundll32.exe": c0000135
wine: configuration in L"/home/vagrant/.wine" has been updated.
013c:err:environ:init_peb starting L"Z:\\vagrant_data\\rubyinstaller-3.0.6-1-x86\\bin\\ruby.exe" in experimental wow64 mode
wine: failed to load L"\\??\\C:\\windows\\syswow64\\ntdll.dll" error c0000135
Application could not be started, or no application associated with the specified file.
ShellExecuteEx failed: Internal error.

メッセージにしたがって以下を実行。32bit用のパッケージがインストールされる:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install wine32:i386

再度実行 → 以下のエラーになる。

  $ WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/bin wine ruby.exe sample.rb
wine: could not load kernel32.dll, status c0000135

一度 ~/.wine を消して作り直す。

rm -rf ~/.wine
wineboot

再度実行 → 以下のエラーになる。

  $ WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/bin wine ruby.exe sample.rb
0118:err:msvcrt:split_oflags :unsupported oflags 0xfff82800
<internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot 
load such file -- dxruby (LoadError)
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from sample.rb:1:in `<main>'

DXRuby をインストール。

  $ WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/bin \
      wine gem install dxruby

Z:\vagrant_data\dxruby>:""||{ ""=> q<-*- ruby -*-
0118:err:msvcrt:split_oflags :unsupported oflags 0xfff82800
Fetching dxruby-1.4.7.gem
Successfully installed dxruby-1.4.7
Parsing documentation for dxruby-1.4.7
Installing ri documentation for dxruby-1.4.7
Done installing documentation for dxruby after 9 seconds
1 gem installed

  $ WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/bin \
      wine gem contents dxruby

Z:\vagrant_data\dxruby>:""||{ ""=> q<-*- ruby -*-
011c:err:msvcrt:split_oflags :unsupported oflags 0xfff82800
Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/2.5/dxruby.so
Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/2.6/dxruby.so
Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/2.6_x64/dxruby.so
Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/2.7/dxruby.so
Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/2.7_x64/dxruby.so
Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/3.0/dxruby.so
Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/3.0_x64/dxruby.so
Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/dxruby.rb

Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems 以下にインストールされた。


再度実行 → 以下のエラーになる。

  $ WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/bin wine ruby.exe sample.rb
0110:err:msvcrt:split_oflags :unsupported oflags 0xfff82800
0110:err:module:import_dll Library libssp-0.dll (which is needed by L"Z:\\vagrant_data\\rubyinstaller-3.0.6-1-x86\\lib\\ruby\\gems\\3.0.0\\gems\\dxruby-1.4.7\\lib\\3.0\\dxruby.so") not found
<internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': 126: Mo
dule not found.   - Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/3.0/dxruby.so (LoadErr
or)
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/dxruby.rb:5:in `<top (required)>'
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `require
'
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue 
in require'
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in `require
'
        from sample.rb:1:in `<main>'
<internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot 
load such file -- dxruby (LoadError)
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.6-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from sample.rb:1:in `<main>'

libssp-0.dll が見つからないとのこと。

RubyInstaller の CHANGELOG によると、3.0.5 から libssp-0.dll を含めなくなったとのこと:

The file <ruby>\bin\ruby_builtin_dlls\libssp-0.dll is no longer shipped as part of RubyInstaller. It is no longer needed with the latest gcc, but previously installed gems with extensions link to this DLL. The dependency to libssp-0.dll is currently still fulfilled by the bundled MSYS2 distribution. To re-compile the gem without this DLL gem pristine --extensions can be used.

  • libssp-0.dll をどこかから持ってくる
  • Ruby 3.0.4 以前を使う
  • DXRuby をビルドしなおす(?)

といった選択肢がありそう。今回は 3.0.4 を使うことに。


rubyinstaller-3.0.4-1-x86 を用意して再度実行 → 以下のエラーになる。

+ WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/bin
+ wine ruby.exe sample.rb
0114:err:msvcrt:split_oflags :unsupported oflags 0xfff82800
0114:err:d3dcompiler:D3DCompile2 Failed to compile shader, vkd3d result -4.
0114:err:d3dcompiler:D3DCompile2 Shader log:
0114:err:d3dcompiler:D3DCompile2     <anonymous>:1:89: E5005: Function "atan2" is not defined.
0114:err:d3dcompiler:D3DCompile2 
<internal:Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': <anonym
ous>:1:89: E5005: Function "atan2" is not defined. (DXRuby::DXRubyError)
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/lib/ruby/gems/3.0.0/gems/dxruby-1.4.7/lib/dxruby.rb:5:in `<top (required)>'
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `require
'
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue 
in require'
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in `require
'
        from sample.rb:1:in `<main>'
<internal:Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot 
load such file -- dxruby (LoadError)
        from <internal:Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from sample.rb:1:in `<main>'

Wine で DirectX を使う場合、大きく

  • WineD3D を使う
  • DXVK を使う

の2パターンがあるらしい。

参考: 第35回 Days of WINE and Struggles again[4] | gihyo.jp

まず DXVK を試したところ、Vulkan 絡みのエラーが出て動かず。VirtualBox の中からは VMware SVGA II Adapter という仮想的なグラフィックドライバ(?)が見えていて、これは Vulkan に対応していないのでダメ(ということだと思います。たぶん。このあたり全然詳しくないので見当違いかも)。

  $ lspci | grep -i vga
00:02.0 VGA compatible controller: VMware SVGA II Adapter

ホスト(VirtualBox の外)側には GeForce GTX 1060 があるのでホスト側でも試してみたが、必要な機能がサポートされてないらしく、自分の環境では動かせず。新しめのグラボだといけるのかもしれません。

  $ lspci | grep -i vga
01:00.0 VGA compatible controller: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] (rev a1)

というわけで DXVK を使うのは諦めて WineD3D を使うことに。

  $ winetricks dlls list | grep directx9
Executing cd /usr/bin
directx9                 MS DirectX 9 (Deprecated, no-op) (Microsoft, 2010) [downloadable]

  $ winetricks dlls list | grep 'd3dx9 '
Executing cd /usr/bin
d3dx9                    MS d3dx9_??.dll from DirectX 9 redistributable (Microsoft, 2010) [downloadable]

directx9 というのもあるが、 deprecated となっているのでスルーして、それっぽい名前の d3dx9 を入れてみる。

winetricks d3dx9
  # メモ: 途中で directx_Jun2010_redist.exe をダウンロードしている

動作確認用スクリプトを再度実行。

WINEPATH=Z:/vagrant_data/rubyinstaller-3.0.4-1-x86/bin \
  wine ruby.exe sample.rb

ウィンドウが表示され図形なども描画できているが、フォント表示の日本語部分が豆腐になる。

cjkfonts をインストール(参考: 第34回 Days of WINE and Struggles again[3] | gihyo.jp):

winetricks cjkfonts

日本語も表示できた。今回はここまででよしとしました。

image.png

参考

この記事を読んだ人は(ひょっとしたら)こちらも読んでいます

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?