Last active
September 28, 2015 14:06
-
-
Save hatajoe/4fd972ff1545418867b6 to your computer and use it in GitHub Desktop.
`runtime/cgo: could not obtain pthread_keys' on darwin/amd64
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
// file: plugins/hello/hello.go | |
// $ go build -o libhello.so -buildmode=c-shared hello.go | |
package main | |
import "C" | |
import ( | |
"log" | |
) | |
//export Hello | |
func Hello() int { | |
log.Println("Hello") | |
return 200 | |
} | |
func init() { | |
log.Println("loaded") | |
} | |
func main() { | |
} |
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
// file: main.go | |
package main | |
import "C" | |
import ( | |
"bitbucket.org/binet/go-ffi/pkg/ffi" | |
"fmt" | |
) | |
func main() { | |
lib, err := ffi.NewLibrary("./plugins/hello/libhello.so") | |
if err != nil { | |
panic(err) | |
} | |
defer lib.Close() | |
fn, err := lib.Fct("Hello", ffi.Int, []ffi.Type{}) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("%#v\n", fn().Int()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here's my environment