I'd like to state my observations (this is not a definitive answer).
On macOS it is okay to ignore the undefined symbols with -undefined dynamic_lookup
On Windows you need to link with a library containing the symbols
On Linux you don't need to care at all... as long as the binary during runtime sees the symbols.
So my build script is something like this:
switch goos {
case "darwin":
cmd.Env = append(cmd.Env, "CGO_CFLAGS: -I/opt/homebrew/opt/lua@5.3/include/lua")
cmd.Env = append(cmd.Env, "CGO_LDFLAGS=-undefined dynamic_lookup")
case "linux":
cmd.Env = append(cmd.Env, "CGO_CFLAGS=-I/usr/include/lua5.3")
case "windows":
cmd.Env = append(cmd.Env, "CGO_CFLAGS=-I/usr/include/lua5.3")
cmd.Env = append(cmd.Env, "CGO_LDFLAGS=-llua53w64 -L/path/to/binary/with/lua/symbols/")
...
With this (don't forget GOOS, GOARCH and CGO_ENABLED) everything compiles (and runs) fine. But there might be pitfalls ignoring all the undefined symbols.
Patrick