go 交叉编译 cgo_enabled
15 December 2022
背景
golang的CGO_ENABLED交叉编译(Linux, Windows)
示例build.bat
set GOARCH=amd64
set GOOS=linux
set CGO_ENABLED=1
set CC=x86_64-linux-musl-gcc
set CXX=x86_64-linux-musl-g++
go build -o build/iot_service ./
makefile
export GOARCH=amd64
export GOOS=linux
export CGO_ENABLED=1
export CC=x86_64-linux-musl-gcc
export CXX=x86_64-linux-musl-g++
build:
@go build -o iot_service ./
.PHONY: build
常见错误
https://blog.csdn.net/weixin_42662249/article/details/116743543