Search code examples
go

go 1.10: cannot implicitly include runtime/cgo in a shared library


I'm trying to execute go build -buildmode=shared -linkshared test but I'm getting the error:

go 1.10: cannot implicitly include runtime/cgo in a shared library

I have only one file in that package

lib.go

package test
import "fmt"
func Hello() {
    fmt.Println("Hi")
}

I'm on a linux machine running go1.10.4 linux/amd64


Solution

  • The problem was I didn't import cgo anywhere. So that means no functions were to be exported which means there's nothing to build into a library.