Mac编译交叉编译Auxpi图床go-sqlite3错误

交叉编译配置

.PHONY: build
build: ## 构建
      GOARCH=amd64 GOOS=linux CGO_ENABLED=1 go build

错误

➜  auxpi git:(dev) ✗      GOARCH=amd64 GOOS=linux CGO_ENABLED=1 go build
# os/user
/usr/local/Cellar/go/1.13/libexec/src/os/user/getgrouplist_unix.go:16:35: warning: passing 'gid_t *' (aka 'unsigned int *') to parameter of type 'int *' converts between pointers to integer types with different sign [-Wpointer-sign]
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:653:43: note: passing argument to parameter here
# github.com/mattn/go-sqlite3
sqlite3-binding.c:32520:42: error: use of undeclared identifier 'pread64'
sqlite3-binding.c:32538:42: error: use of undeclared identifier 'pwrite64'
sqlite3-binding.c:32670:22: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
sqlite3-binding.c:32679:22: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
sqlite3-binding.c:32706:20: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
sqlite3-binding.c:32723:16: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
sqlite3-binding.c:13942:38: note: expanded from macro 'ArraySize'
sqlite3-binding.c:32727:14: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
sqlite3-binding.c:13942:38: note: expanded from macro 'ArraySize'
sqlite3-binding.c:35377:11: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
sqlite3-binding.c:32524:49: note: expanded from macro 'osPread64'
sqlite3-binding.c:35489:17: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
sqlite3-binding.c:32542:57: note: expanded from macro 'osPwrite64'

解决之道

Mac未安装linux的交叉编译器。解决方法,安装linux的交叉编译器。

wget http://crossgcc.rts-software.org/download/gcc-4.8.1-for-linux32-linux64/gcc-4.8.1-for-linux64.dmg


可能下载很慢需要科学一下, CLashX配置一下加速crossgcc.rts-software.org

Clashx配置

- DOMAIN-SUFFIX,crossgcc.rts-software.org,PROXY

然后安装gcc-linux64

编译

export CGO_ENABLED=1
export GOOS=linux
export GOARCH=amd64
export CC=/usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-gcc
# 重新编译
go build
Last modification:September 24th, 2019 at 12:00 am
搞技术/肝文章不易,恳请随意打赏 OwO

Leave a Comment