- sudo dnf install perl-ExtUtils-MakeMaker perl-Thread-Queue perl-FindBin perl-English perl-IPC-Cmd
- sudo dnf install autoconf
- sudo dnf install make ncurses-devel wget bc rsync
- sudo dnf install gcc-c++
- sudo dnf install zlib-devel glibc-devel libgcc
git clone https://github.com/buildroot/buildroot.git --depth=1
cd buildroot
make menuconfig
Target Options
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Target Architecture (ARM (little endian)) ---> │ │
│ │ Target Architecture Variant (cortex-A15) ---> │ │
│ │ Target ABI (EABIhf) ---> │ │
│ │ Floating point strategy (VFPv4-D16) ---> │ │
│ │ ARM instruction set (ARM) ---> │ │
│ │ Target Binary Format (ELF) ---> │ │
选ARM 小端
A15
其他默认
实际如上
Toolchin -->
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Toolchain type (Buildroot toolchain) ---> │ │
│ │ *** Toolchain Buildroot Options *** │ │
│ │ (buildroot) custom toolchain vendor name │ │
│ │ C library (glibc) ---> │ │
│ │ *** Kernel Header Options *** │ │
│ │ Kernel Headers (Linux 6.18.x kernel headers) ---> │ │
│ │ *** Glibc Options *** │ │
│ │ [ ] Enable compatibility shims to run on older kernels │ │
│ │ [ ] Install glibc utilities │ │
│ │ *** Binutils Options *** │ │
│ │ Binutils Version (binutils 2.45.1) ---> │ │
│ │ [ ] gprofng support │ │
│ │ () Additional binutils options │ │
│ │ *** GCC Options *** │ │
│ │ GCC compiler Version (gcc 15.x) ---> │ │
│ │ () Additional gcc options │ │
│ │ [*] Enable C++ support │ │
│ │ [ ] Enable Fortran support │ │
│ │ [ ] Enable compiler OpenMP support │ │
│ │ [ ] Enable graphite support │ │
│ │ *** Host GDB Options *** │ │
│ │ [*] Build cross gdb for the host │ │
│ │ [ ] TUI support │ │
│ │ [ ] Python support │ │
│ │ [ ] Simulator support │ │
│ │ GDB debugger Version (gdb 15.x) ---> │ │
│ │ *** Toolchain Generic Options *** │ │
│ │ [ ] Copy gconv libraries │ │
│ │ () Extra toolchain libraries to be copied to target │ │
│ │ () Target Optimizations │ │
│ │ () Target linker options │ │
│ │ *** Bare metal toolchain *** │ │
│ │ [ ] Build bare metal toolchains │ │
│ │ │ │
C library (glibc)
Kernel Headers (Linux 6.18.x kernel headers)
Binutils Version (binutils 2.45.1)
GCC compiler Version (gcc 15.x)
GDB debugger Version (gdb 15.x) --->
其他默认
最后make 得到output/host 这个就包含gcc 和 sysroot的目录
将host mv 到 /opt/host-arm64-armhf下
sudo ln -s /opt/host-arm64-armhf//opt/host-arm64-armhf/arm-buildroot-linux-gnueabihf/sysroot/lib/ld-linux-armhf.so.3 /lib/ld-linux-armhf.so.3
创建/etc/ld.so.conf.d/armhf.conf 文件
文件添加
/opt/host-arm64-armhf//opt/host-arm64-armhf/arm-buildroot-linux-gnueabihf/sysroot/lib
sudo ldconfig
git clone https://github.com/ptitSeb/box86.git --depth=1
cd box86/
cd build/
cmake .. -DSD888=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=/opt/host-arm64-armhf/bin/arm-linux-gcc
make -j4
sudo make install
重启服务
sudo systemctl restart systemd-binfmt.service
已同样的方式编译i686-gcc,设置运行库 ~/.bashrc 添加Path
export PATH=/opt/host-arm64-i686/bin:$PATH
export PATH=/opt/host-arm64-armhf/bin:$PATH
export PATH=/opt/host-arm64-x86_64/bin:$PATH
测试程序
#include<stdio.h>
int main() {
printf("i686\n");
}box86
cfm880@nabu:~/Downloads$ i686-linux-gcc hello.c -o test_hello_i686
cfm880@nabu:~/Downloads$ ./test_hello_i686
[binfmt_dispatcher] Using box86
Box86 v0.3.9 0579f8b built on Mar 3 2026 22:43:47
i686
box64
cfm880@nabu:~/Downloads$ x86_64-linux-gcc hello.c -o test_hello_x64
cfm880@nabu:~/Downloads$ ./test_hello_x64
[BOX64] Box64 arm64 v0.4.1 3acd719 with Dynarec built on Mar 4 2026 18:12:53
[BOX64] Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2
[BOX64] Running on Kryo-4XX-Gold with 8 cores, pagesize: 4096
[BOX64] Will use hardware counter measured at 19.2 MHz emulating 2.4 GHz
[BOX64] Detected 48bits at least of address space
[BOX64] Counted 40 Env var
[BOX64] Library search path:
[BOX64] Binary search path: ./:bin/:/opt/host-arm64-x86_64/bin/:/opt/host-arm64-armhf/bin/:/opt/host-arm64-i686/bin/:/home/cfm880/.local/bin/:/home/cfm880/bin/:/usr/local/bin/:/usr/bin/
[BOX64] Looking for /home/cfm880/Downloads/test_hello_x64
[BOX64] argv[1]="./test_hello_x64"
[BOX64] argv[2]="./test_hello_x64"
[BOX64] Rename process to "test_hello_x64"
[BOX64] Using native(wrapped) libc.so.6
[BOX64] Using native(wrapped) ld-linux-x86-64.so.2
[BOX64] Using native(wrapped) libpthread.so.0
[BOX64] Using native(wrapped) libdl.so.2
[BOX64] Using native(wrapped) libutil.so.1
[BOX64] Using native(wrapped) libresolv.so.2
[BOX64] Using native(wrapped) librt.so.1
[BOX64] Using native(wrapped) libbsd.so.0
i686