Go交叉编译CGO提示undefined

在linux下面交叉编译windows版本的sciter的代码, 提示一堆未定义变量
编译linux版本的就没问题

$go build .
$CC=x86_64-w64-mingw32-gcc GOOS=windows go build .
# github.com/sciter-sdk/go-sciter
../../github.com/sciter-sdk/go-sciter/types_string.go:27:9: undefined: BehaviorEvent
../../github.com/sciter-sdk/go-sciter/types_string.go:62:9: undefined: MouseEvent
../../github.com/sciter-sdk/go-sciter/types_string.go:78:9: undefined: CursorType
../../github.com/sciter-sdk/go-sciter/types_string.go:89:9: undefined: KeyEvent
../../github.com/sciter-sdk/go-sciter/types_string.go:100:9: undefined: FocusEvent
../../github.com/sciter-sdk/go-sciter/types_string.go:111:9: undefined: ScrollEvent
../../github.com/sciter-sdk/go-sciter/types_string.go:122:9: undefined: GestureCmd
../../github.com/sciter-sdk/go-sciter/types_string.go:139:9: undefined: GestureState
../../github.com/sciter-sdk/go-sciter/types_string.go:171:9: undefined: GestureTypeFlag
../../github.com/sciter-sdk/go-sciter/types_string.go:197:9: undefined: DrawEvent
../../github.com/sciter-sdk/go-sciter/types_string.go:197:9: too many errors

查了半天, 发现是CGO_ENABLED的锅, 交叉编译的时候, 这个选项默认为0了, 手动设了后编译通过.

CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows go build .

你可能感兴趣的:(go)