【问题标题】:Ruby FFI gem cannot open library fileRuby FFI gem 无法打开库文件
【发布时间】:2019-10-31 17:29:05
【问题描述】:

我在同一路径中有两个文件,functions.dll 和 functions.rb,其中包含以下内容:

require 'ffi'

module Foos
  extend FFI::Library
  ffi_lib 'functions'
end

当我运行它时,它会抛出:

Traceback (most recent call last):

        4: from functions.rb:6:in <main>
        3: from functions.rb:9:in <module:Foos>
        2: from C:/Ruby/lib/ruby/gems/2.5.0/gems/ffi-1.11.1-x64-mingw32/lib/ffi/library.rb:98:in ffi_lib
        1: from C:/Ruby/lib/ruby/gems/2.5.0/gems/ffi-1.11.1-x64-mingw32/lib/ffi/library.rb:98:in map

C:/Ruby/lib/ruby/gems/2.5.0/gems/ffi-1.11.1-x64-mingw32/lib/ffi/library.rb:151:in block in ffi_lib: Could not open  (LoadError): The specified module could not be found.
Could not open library 'functions.dll': The specified module could not be found.


知道为什么它可能找不到文件吗?

【问题讨论】:

    标签: ruby ffi


    【解决方案1】:

    为其提供完整路径。

    ffi_lib File.dirname(__FILE__) + '/functions.dll'
    

    ffi_lib File.dirname(__FILE__) + '/functions'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-11
      • 2018-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-18
      相关资源
      最近更新 更多