Skip to content

Instantly share code, notes, and snippets.

@CFM880
Last active March 4, 2026 10:36
Show Gist options
  • Select an option

  • Save CFM880/a649a90544cd4628e5dd3e45da4d2efd to your computer and use it in GitHub Desktop.

Select an option

Save CFM880/a649a90544cd4628e5dd3e45da4d2efd to your computer and use it in GitHub Desktop.
fedora arm64 install box86

0. 安装依赖

  1. sudo dnf install perl-ExtUtils-MakeMaker perl-Thread-Queue perl-FindBin perl-English perl-IPC-Cmd
  2. sudo dnf install autoconf
  3. sudo dnf install make ncurses-devel wget bc rsync
  4. sudo dnf install gcc-c++
  5. sudo dnf install zlib-devel glibc-devel libgcc

1. 下载buildroot

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的目录

3.设置运行时lib库

将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

4. 下载编译box86

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

5. 设置binfmt

重启服务
sudo systemctl restart systemd-binfmt.service

7. 测试

已同样的方式编译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

准备

下载交叉编译工具

  1. 访问:https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads

  2. AArch32 GNU/Linux target with hard float (arm-none-linux-gnueabihf)

  3. 解压搭到/opt

    得到路径为/opt/arm-gnu-toolchain-15.2.rel1-aarch64-arm-none-linux-gnueabihf/bin/

  4. 安装cmake,git

  5. 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/arm-gnu-toolchain-15.2.rel1-aarch64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gc
sudo make install

设置运行库

获取运行库

wget http://ftp.debian.org/debian/pool/main/c/cross-toolchain-base/libc6-armhf-cross_2.42-12cross1_all.deb
wget http://ftp.debian.org/debian/pool/main/g/gcc-15-cross/libgcc-s1-armhf-cross_15.2.0-13cross1_all.deb
wget http://ftp.debian.org/debian/pool/main/g/gcc-15-cross/libstdc++6-armhf-cross_15.2.0-13cross1_all.deb

设置运行库

  1. 解压 将上述deb解压, 例如~/Download/usr/arm-linux-gnueabihf/lib

lib 文件如下

总计 5484
drwxr-xr-x 2 cfm880 cfm880    4096  3月 2日 19:55 .
drwxr-xr-x 3 cfm880 cfm880    4096  3月 2日 19:58 ..
-rwxr-xr-x 1 cfm880 cfm880 1118020  2月 8日 23:32 ld-linux-armhf.so.3
-rw-r--r-- 1 cfm880 cfm880   67036  2月 8日 23:32 libanl.so.1
-rw-r--r-- 1 cfm880 cfm880   66932  2月 8日 23:32 libBrokenLocale.so.1
-rw-r--r-- 1 cfm880 cfm880   68172  2月 8日 23:32 libc_malloc_debug.so.0
-rwxr-xr-x 1 cfm880 cfm880 1188080  2月 8日 23:32 libc.so.6
-rw-r--r-- 1 cfm880 cfm880   66932  2月 8日 23:32 libdl.so.2
-rw-r--r-- 1 cfm880 cfm880  132652  2月 8日 22:32 libgcc_s.so.1
-rw-r--r-- 1 cfm880 cfm880   66980  2月 8日 23:32 libmemusage.so
-rw-r--r-- 1 cfm880 cfm880  329136  2月 8日 23:32 libm.so.6
-rw-r--r-- 1 cfm880 cfm880   66932  2月 8日 23:32 libnsl.so.1
-rw-r--r-- 1 cfm880 cfm880   67156  2月 8日 23:32 libnss_compat.so.2
-rw-r--r-- 1 cfm880 cfm880   66932  2月 8日 23:32 libnss_dns.so.2
-rw-r--r-- 1 cfm880 cfm880   66932  2月 8日 23:32 libnss_files.so.2
-rw-r--r-- 1 cfm880 cfm880   66932  2月 8日 23:32 libnss_hesiod.so.2
-rw-r--r-- 1 cfm880 cfm880   66876  2月 8日 23:32 libpcprofile.so
-rw-r--r-- 1 cfm880 cfm880   66932  2月 8日 23:32 libpthread.so.0
-rw-r--r-- 1 cfm880 cfm880   67052  2月 8日 23:32 libresolv.so.2
-rw-r--r-- 1 cfm880 cfm880   66984  2月 8日 23:32 librt.so.1
lrwxrwxrwx 1 cfm880 cfm880      19  2月 8日 22:32 libstdc++.so.6 -> libstdc++.so.6.0.34
-rw-r--r-- 1 cfm880 cfm880 1712576  2月 8日 22:32 libstdc++.so.6.0.34
-rw-r--r-- 1 cfm880 cfm880   67224  2月 8日 23:32 libthread_db.so.1
-rw-r--r-- 1 cfm880 cfm880   66932  2月 8日 23:32 libutil.so.1

将lib下的文件copy到/opt/armhf-libc6/arm-linux-gnueabihf/lib下

  1. 建立软链接
sudo ln -sf /opt/armhf-libc6/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /lib/ld-linux-armhf.so.3
  1. 添加环境变量到~/.bashrc
export LD_LIBRARY_PATH=/opt/armhf-libc6/arm-linux-gnueabihf/lib:$LD_LIBRARY_PATH
  1. 运行测试
cfm880@nabu:~$ box86 --version
Box86 v0.3.9 0579f8b built on Mar  2 2026 20:31:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment