macOS: 12.5.1
go: go1.19.3 darwin/amd64
I'm having trouble building a go module that uses Python as a shared library.
This code works:
...
package main
// #include <float.h>
import "C"
import "fmt"
func main() {
fmt.Println("Max float value of float is", C.FLT_MAX)
}
...
$ go run .
Max float value of float is 3.4028234663852886e+38
...
I run into problems when I try to include Python:
...
package main
/*
#cgo pkg-config: python3
#cgo LDFLAGS: -lpython3.8
*/
import "C"
import (
"fmt"
)
func main() {
C.Py_Initialize()
fmt.Println(C.GoString(C.Py_GetVersion()))
C.Py_Finalize()
}
...
$ go run .
# producer
./producer.go:16:2: could not determine kind of name for C.Py_Finalize
./producer.go:15:25: could not determine kind of name for C.Py_GetVersion
./producer.go:14:2: could not determine kind of name for C.Py_Initialize
...
Any suggestions? I'm guessing it has something to do w/ setting PKG_CONFIG_PATH and/or CGO_CFLAGS but I'm not certain...