Hello all, I try to build a Go library that uses Lua. This library will be used together with an executable that contains the Lua functions, so I (believe) I don't need to have the dynamic Lua library.
My code: ~~~ package main /* #include <lauxlib.h> #include <lua.h> #include <lualib.h> #include <stdlib.h> #cgo CFLAGS: -I/opt/homebrew/opt/lua@5.3/include/lua */ import "C" import "fmt" func foo(L *C.lua_State) int { fmt.Println(C.lua_gettop(L)) return 0 } func main() {} ~~~ and the command line to compile (on the latest macOS X) go build -buildmode=c-shared mylib.go but the output is: # command-line-arguments /opt/homebrew/Cellar/go/1.21.0/libexec/pkg/tool/darwin_arm64/link: running cc failed: exit status 1 ld: Undefined symbols: _lua_gettop, referenced from: __cgo_513e18cdc587_Cfunc_lua_gettop in 000001.o clang: error: linker command failed with exit code 1 (use -v to see invocation) How can I fix this? I know I can set the environment variable CGO_LDFLAGS to "-undefined dynamic_lookup" before running the compile command, but this 1) does not sound like a good fix and 2) doesn't work for my cross commpile environment using migw on linux. Any suggestions? Thank you very much Patrick -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/37c72a4e-da7e-42c4-b850-de5a9f9d861an%40googlegroups.com.