我正在使用Docker容器( thewtex/cross-compiler-linux-armv7 )在Fedora 23 x86_64系统上交叉编译一个简单的“Hello World”Linux用户空间C程序。 目标系统是ARMv7embedded式系统(特别是带库存固件的Kobo Aura HD电子阅读器)。
程序的源代码( hello_world.c )如下
#include int main(int argc, char *argv[]) { printf("Hello World!\n"); return 0; }
我使用以下一组命令调用编译器
docker run thewtex/cross-compiler-linux-armv7 > ./dockcross.sh chmod +x dockcross.sh
出于某种原因,生成的shell脚本是错误的,我手动必须replace/cross-compiler-base/cross-compiler-linux-armv7/和/:build/:build:z/ 。 现在我跑了./dockcross.sh arm-linux-gnueabihf-cc hello_world.c -static -o hello
file返回有关生成的hello可执行file的以下信息
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=317a9ea164931f614b24e98dec743050e2d7f900, not stripped
意外的是,我可以在主机系统上执行产生的可执行文件:
andreas@andreas-pc:~/tmp/test$ uname -a && ./hell