如何交叉编译,有点懵了

查看 61|回复 2
作者:oneisall8955   
最近折腾随身 Wi-Fi ,看到别人开源了 at_server ,仓库如下: https://github.com/newton-miku/jc09
我在 amd64 主机里面编译好了,编译出的执行文件在 amd64 可以运行。但是随身 Wi-Fi 是 arm64 的,需要交叉编译才可以。
里面有个 makefile 如下:
Makefile
OUTDIR=build
CC = gcc
CFLAGS = $(shell pkg-config --cflags glib-2.0 gio-2.0)
LIBS = $(shell pkg-config --libs glib-2.0 gio-2.0) -lpthread
main: main.c mongoose.c
        $(CC) -o $(OUTDIR)/main main.c mongoose.c $(CFLAGS) $(LIBS)
这个随身 Wi-Fi 的系统信息如下:
root@udx710-module:/ # uname -a
Linux udx710-module 4.14.98 #1 SMP PREEMPT Thu Jul 27 01:59:03 UTC 2023 aarch64 GNU/Linux
root@udx710-module:/ # uname -r
4.14.98
oot@udx710-module:/ # /lib/libc-2.27.so
GNU C Library (GNU libc) stable release version 2.27.
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 7.2.1 20171011.
libc ABIs: UNIQUE
For bug reporting instructions, please see:
.
我应该如何修改 makefile ,使用交叉编译的工具链编译出 arm64 的执行文件呢?

gnu, main, 编译, libs

AFOX   
替换 cc ,改成交叉编译工具链 arm-linux-gcc 的路径,如果依赖其他库,需要将第三方库也改成交叉编译后的库
lhbc   
可以用这个工具链
https://github.com/userdocs/qbt-musl-cross-make
我用这个轻易就把一些工具编译成十几个架构的
您需要登录后才可以回帖 登录 | 立即注册

返回顶部