所以我一直试图解决这个问题,并且不太了解Ruby以便完全理解这个问题。
所以我想用ruby脚本播放声音。所以在安装Ruby 2.2.1之后,我安装了最新版本的gem,然后继续下载win32-sound add on,如下所示
gem install win32-sound
安装完成后,我尝试使用以下代码从命令行运行一个简单的脚本
require 'win32/sound'
include Win32
Sound.play('chimes.wav')
但是当我这样做时,我最终得到了如下错误
C:/Program Files/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- ffi_c (LoadError)
from C:/Program Files/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Program Files/Ruby22-x64/lib/ruby/gems/2.2.0/gems/ffi-1.9.8-x64-mingw32/lib/ffi.rb:18:in `rescue in <top (required)>'
from C:/Program Files/Ruby22-x64/lib/ruby/gems/2.2.0/gems/ffi-1.9.8-x64-mingw32/lib/ffi.rb:3:in `<top (required)>'
from C:/Program Files/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Program Files/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Program Files/Ruby22-x64/lib/ruby/gems/2.2.0/gems/win32-sound-0.6.0/lib/win32/windows/functions.rb:1:in `<top (required)>'
from C:/Program Files/Ruby22-x64/lib/ruby/gems/2.2.0/gems/win32-sound-0.6.0/lib/win32/sound.rb:1:in `require_relative'
from C:/Program Files/Ruby22-x64/lib/ruby/gems/2.2.0/gems/win32-sound-0.6.0/lib/win32/sound.rb:1:in `<top (required)>'
from C:/Program Files/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from C:/Program Files/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from C:/Program Files/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from player.rb:1:in `<main>'
我有点困惑。我以为我已经正确安装了所有东西,但现在我不太确定。