Skip to content
Discussion options

You must be logged in to vote

我为斐讯K3交叉编译成功了,希望这些笔记对想自己编译的同学有所帮助:
Alist要用到sqlite3,需为go安装go-sqlite3驱动
#以下指令要在Alist项目目录下才能正确运行
安装go get:go get
安装go-sqlite3:go get github.com/mattn/go-sqlite3@latest //需要配合下面CGO_ENABLED、CGO_LDFLAGS、CC、CXX、AR配置的环境变量将sqlite3静态编译到Alist才能正常工作,各平台musl GCC编译器到https://musl.cc/下载

为go配置环境变量(前三条跨平台交叉编译才需要配置,编译本地程序默认即可):
export GOOS=linux //指定交叉编译生成的可执行文件之目标系统
export GOARCH=arm //指定交叉编译生成的可执行文件之目标CPU构架
export GOARM=5 //指定交叉编译生成的可执行文件之目标CPU类型,仅在GOARCH=arm时有效
export CGO_ENABLED=1 //开启使用GCC编译器
export CGO_LDFLAGS="-static" //一定要将目标平台对应的musl GCC库(如斐讯K3就用arm-linux-musleabi-cross)静态编译到可执行文件中,否则到目标平台运行大概率会出现not found错误
export CC=/...保存路径.../arm-linux-musleabi-cross/bin/arm-linux-musleabi-gcc //为go-sqlite3指定目…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@anwen-anyi
Comment options

@Hermit-Nameless
Comment options

@gsoyond
Comment options

@evan618
Comment options

@Hermit-Nameless
Comment options

Answer selected by Hermit-Nameless
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants