我正在try 在CentOS 7 64位机器上交叉编译Hello world C程序,并将其与Raspberry PI 2B 32位目标机器交叉编译.
我下载了巴斯特交叉编译器cross-gcc-8.3.0-pi_2-3.tar.gz
我的Hello world C文件是我们都使用的标准Hello World程序.
当我一步一步地编写我的编译程序时,我只是想要编译
arm-linux-gnueabihf-gcc -o helloworld.exe helloworld.c
给了我:
/home/<redacted>/repos/pi-2-compiler/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /lib64/libc.so.6: version `GLIBC_2.27' not found (required by /home/<redacted>/repos/pi-2-compiler/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld)
collect2: error: ld returned 1 exit status
我的CentOS机器上的libc版本与目标机器上的版本不同.libc.so.6
文件位于交叉编译路径中,因此当我使用--sysroot
选项时,我克服了libc问题,但无法找到stdio.h
文件.
arm-linux-gnueabihf-gcc -o helloworld.exe helloworld.c --sysroot=/home/<redacted>/repos/pi-2-compiler/cross-pi-gcc-8.3.0-1/arm-linux-gnueabihf/libc/lib
helloworld.c:1:10: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^~~~~~~~~
compilation terminated.
H文件位于交叉编译路径中,但我无法确定如何在不 destruct 与libc世界的链接的情况下将该路径添加到gcc
命令中.我试过了-我,-系统,...但当我这样做时,我得到了原始的GLIBC错误
我不是在发明轮子,所以我肯定遗漏了什么.我刚刚开始做这个交叉编译的工作,需要帮助来增加我的知识.我看了五月的网站,但还没有完全找到答案.
谢谢你的帮助.