go build -buildmode=c-shared -o sum.so sum.go
ruby link.rb
-
-
Save brainwire/b4d451910d1e6f700ae4 to your computer and use it in GitHub Desktop.
Linking #GoLang lib in #Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
module FfiCustomTest | |
extend FFI::Library | |
ffi_lib 'c' | |
ffi_lib './sum.so' | |
attach_function :sum, [:int, :int], :int | |
end | |
puts FfiCustomTest.sum(1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "C" | |
//export sum | |
func sum(a, b int) int { | |
return a + b | |
} | |
func main() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment