ruby - 如何修复(RubyInstaller::Runtime::DllDirectory::WinApiError) in ruby on windows?

标签 ruby compiler-errors rubygems runtime-error runtime

在代码中实现ruby2d时出现此错误

这是一个奇怪的运行时问题

Ruby2d代码

require 'ruby2d'
# Set the window size
set width: 300, height: 200
# Create a new shape
s = Square.new
# Give it some color
s.color = 'red'
# Show the window
 show

错误
  8: from R.rb:1:in `<main>'
    7: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
    6: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    5: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
    4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/ruby2d-0.5.1/lib/ruby2d.rb:28:in `<top (required)>'
    3: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/singleton.rb:12:in `add_dll_directory'
    2: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/singleton.rb:12:in `new'
    1: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/dll_directory.rb:50:in `initialize'


*C:/Ruby25- 
x64/lib/ruby/site_ruby/2.5.0/ruby_installer/runtime/dll_directory.rb:83:in 
`add_dll_directory_winapi': AddDllDirectory failed for 
C:/Users/Salim/usr/local/bin 
(RubyInstaller::Runtime::DllDirectory::WinApiError)*

,请帮助我修复

最佳答案

您必须从MINGW 64位命令提示符下运行项目。不是从常规的DOS提示符(Windows命令提示符)。

确保遵循以下说明:
http://www.ruby2d.com/learn/windows/

注意最后一段:

Using Ruby 2D on Windows

When working with Ruby 2D, make sure to use a MinGW 64-bit command prompt, rather than a standard one (cmd.exe) or the “Start Command Prompt with Ruby” found in the Start menu.

关于ruby - 如何修复(RubyInstaller::Runtime::DllDirectory::WinApiError) in ruby on windows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51658119/

相关文章:

ruby-on-rails - Rails 4 中动态表单的不允许参数

Ruby:Random#rand 和 Kernel#rand 之间的区别

每行都有 Java Eclipse 错误

ruby - Gemfile 中的 jeweler 和 gemspec 是否一起工作?

ruby - 如何从 Unix 将 DOS 行结尾写入文件

ruby-on-rails - 日期时间到时间转换中奇怪的 Ruby 行为

C++ Variadic 模板 - 无法找出编译错误

c# - 为什么C#限制了可以声明为const的类型集?

ruby-on-rails - Node/NPM 依赖于 Ruby on Rails 引擎 gem Assets 管道

ruby - 在非 Rails/Rack 项目中使用 Sprockets — rake 编译命令出现错误