Skip to content

Instantly share code, notes, and snippets.

@r3n4ud
Created November 30, 2012 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r3n4ud/4179560 to your computer and use it in GitHub Desktop.
Save r3n4ud/4179560 to your computer and use it in GitHub Desktop.
Unable to find foreign function in rubinius
$ ruby -rlibusb -e ''
An exception occurred requiring command line files
Unable to find foreign function '[:libusb_device_handle, :int]' (FFI::NotFoundError)
Backtrace:
FFI::Library(Module)#ffi_function_missing at kernel/delta/ffi.rb:9
FFI::Library(Module)#attach_function at kernel/platform/library.rb:130
LIBUSB::Call.__module_init__ (Call) at /home/renaud/.rbenv/versions/rbx-2.0.0-dev/gems/1.9/gems/libusb-0.2.2/lib/libusb/call.rb:192
LIBUSB.__module_init__ (LIBUSB) at /home/renaud/.rbenv/versions/rbx-2.0.0-dev/gems/1.9/gems/libusb-0.2.2/lib/libusb/call.rb:21
Object#__script__ at /home/renaud/.rbenv/versions/rbx-2.0.0-dev/gems/1.9/gems/libusb-0.2.2/lib/libusb/call.rb:19
Rubinius::CodeLoader.require at kernel/common/codeloader.rb:212
Kernel(Module)#gem_original_require (require) at kernel/common/kernel.rb:648
Kernel(Module)#require at /home/renaud/.rbenv/versions/rbx-2.0.0-dev/lib/rubygems/custom_require.rb:36
LIBUSB.__module_init__ (LIBUSB) at /home/renaud/.rbenv/versions/rbx-2.0.0-dev/gems/1.9/gems/libusb-0.2.2/lib/libusb.rb:19
Object#__script__ at /home/renaud/.rbenv/versions/rbx-2.0.0-dev/gems/1.9/gems/libusb-0.2.2/lib/libusb.rb:16
Rubinius::CodeLoader.require at kernel/common/codeloader.rb:212
Kernel(Rubinius::Loader)#gem_original_require (require) at kernel/common/kernel.rb:648
Kernel(Rubinius::Loader)#require at /home/renaud/.rbenv/versions/rbx-2.0.0-dev/lib/rubygems/custom_require.rb:60
{ } in Rubinius::Loader#requires at kernel/loader.rb:568
Array#each at kernel/bootstrap/array.rb:68
Rubinius::Loader#requires at kernel/loader.rb:568
Rubinius::Loader#main at kernel/loader.rb:814
typedef :pointer, :libusb_context
typedef :pointer, :libusb_device_handle
attach_function 'libusb_set_configuration', [:libusb_device_handle, :int], :int, :blocking=>true
attach_function 'libusb_claim_interface', [:libusb_device_handle, :int], :int
attach_function 'libusb_release_interface', [:libusb_device_handle, :int], :int, :blocking=>true
[…]
attach_function 'libusb_handle_events', [:libusb_context], :int, :blocking=>true
diff --git a/lib/libusb/call.rb b/lib/libusb/call.rb
index e0604b7..252ee86 100644
--- a/lib/libusb/call.rb
+++ b/lib/libusb/call.rb
@@ -21,7 +21,7 @@ module LIBUSB
module Call
extend FFI::Library
- if FFI::Platform.windows?
+ if FFI::Platform::OS == 'windows'
bundled_dll = File.join(File.dirname(__FILE__), '..', 'libusb-1.0.dll')
ffi_lib(['libusb-1.0', bundled_dll])
else
diff --git a/lib/libusb/call.rb b/lib/libusb/call.rb
index e0604b7..252ee86 100644
--- a/lib/libusb/call.rb
+++ b/lib/libusb/call.rb
@@ -21,7 +21,7 @@ module LIBUSB
module Call
extend FFI::Library
- if FFI::Platform.windows?
+ if FFI::Platform::OS == 'windows'
bundled_dll = File.join(File.dirname(__FILE__), '..', 'libusb-1.0.dll')
ffi_lib(['libusb-1.0', bundled_dll])
else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment