Calling functions in an so file from Go

前端 未结 3 1063
再見小時候
再見小時候 2020-12-31 14:30

Is it possible to call a static object (.so) file from Go? I\'ve been searchign Google and I keep hitting upon the claim that I can do

lib, _ := syscall.Load         


        
3条回答
  •  执笔经年
    2020-12-31 15:05

    As @JimB said, you should just use CGO, and put the linking to the dynamic/static library there. as per this example:

    // #cgo LDFLAGS: -lpng
    // #include 
    import "C"
    
    ...
    
    var x:= C.png_whatever() // whatever the API is
    

    Read more here: http://blog.golang.org/c-go-cgo

提交回复
热议问题