go build -buildmode=c-shared -o sum.so sum.go
ruby link.rb
Last active
January 11, 2017 19:39
-
-
Save vodafon/89c2a9fb22cb74303c68 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