我为 ARM 嵌入式设备(运行 DD-WRT 的华硕 RT-AC68U 路由器)交叉编译了一个小型 Hello World 程序:
# arm-linux-gnueabi-g++ hello.cpp -mcpu=cortex-a9 -s -o hello
Run Code Online (Sandbox Code Playgroud)
该文件看起来不错:
# file hello
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.32,
BuildID[sha1]=5099693c31154cdd7f04c16ced5b80b1e35e625b, stripped
Run Code Online (Sandbox Code Playgroud)
它依赖于几个库:
# readelf -d hello
Dynamic section at offset 0xf08 contains 26 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
(...)
Run Code Online (Sandbox Code Playgroud)
当我尝试在目标系统上执行该文件时,我得到以下信息:
# ./hello
-sh: ./hello: not found …Run Code Online (Sandbox Code Playgroud)