RK3568开发板Buildroot系统GCC编译Hello World报错求助
RK3568 Buildroot环境下GCC编译Hello World链接错误排查
环境说明
- 硬件/系统:基于RK3568 SoC的自定义Buildroot发行版(内核版本4.19)
- 编译器:已安装GCC 11.4.0
- 交叉编译环境:Windows 11下的WSL2
首次编译错误
执行编译命令:
gcc -g -ansi -pedantic -Wall hello.c -o hello
得到错误输出:
/usr/lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: /usr/lib64/libc_nonshared.a: error adding symbols: archive has no index; run ranlib to add one collect2: error: ld returned 1 exit status
仅编译为目标文件时可成功,执行命令:
gcc -c -g -ansi -pedantic -Wall hello.c -o hello.o
用file命令查看目标文件:
hello.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), with debug_info, not stripped
说明编译的目标平台是正确的。
执行ranlib后的新错误
对提示的库执行ranlib命令:
ranlib /usr/lib64/libc_nonshared.a
再次执行编译命令后出现新错误:
/usr/lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: error in /usr/lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/../../../../lib64/crt1.o(.eh_frame); no .eh_frame_hdr table will be created /usr/lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400440
补充说明与疑问
补充说明:在WSL2环境中直接用gcc编译出的hello.o,file命令显示内容翻译为:
hello.o:64位LSB可重定位ELF文件,x86-64架构,版本1(SYSV),含调试信息,未剥离符号
初步推测crt1.o(.eh_frame); no .eh_frame_hdr table will be created错误可能与重复定义(如重复包含同一文件)有关,但不确定,作为编译器和链接器新手,需要排查方向。
内容的提问来源于stack exchange,提问作者hal
相关产品推荐
相关产品推荐

