Skip to content

Instantly share code, notes, and snippets.

@folkengine
Last active July 28, 2016 13:53
Show Gist options
  • Select an option

  • Save folkengine/a7c642119144ad108537 to your computer and use it in GitHub Desktop.

Select an option

Save folkengine/a7c642119144ad108537 to your computer and use it in GitHub Desktop.
Example of a cross-platform ffi embed in Ruby
require 'rbconfig'
require 'ffi'
include RbConfig
# Example of a cross-platform ffi embed in Ruby.
module Hello
extend FFI::Library
if CONFIG['host_os'] =~ /linux/i
ffi_lib 'target/release/libembed.so'
elsif CONFIG['host_os'] =~ /mswin|windows|mingw/i
fi_lib 'target/release/libembed.ddl'
else
ffi_lib 'target/release/libembed.dylib'
end
attach_function :process, [], :void
end
Hello.process
puts 'Tis\' done!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment