使用 arm-none-eabi-gcc 编译并链接库 liba.a 错误 [英] Compiling using arm-none-eabi-gcc and linking library liba.a error

查看:281
本文介绍了使用 arm-none-eabi-gcc 编译并链接库 liba.a 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 64 位 Linux 机器上用 C 编译一个 hello world 程序.我正在使用 GCC ARM 嵌入式工具链在带有 ATMEL AT91SAM9G20 处理器的 FOX G20 V 板上交叉编译我的程序.

I am compiling a hello world program in C on a 64-bit Linux machine. I am using a GCC ARM embedded toolchain to cross compile my program on a FOX G20 V board with an ATMEL AT91SAM9G20 processor.

在第一次尝试时,我在编译时遇到了一些错误,因为程序无法识别 printf、return 等函数(标准 C 函数).所以我决定通过执行 arm-none-eabi-gcc -o hello hello.c 来建立函数之间的链接,我相信这些函数是在 libc.a 库中定义的(如果我错了,请纠正我)libc.a 但结果仍然导致错误:

On the first take, I had a few errors when compiling because the program didn't recognize the printf, return etc. functions (the standard C functions). So I decided to make the link between the functions, which I believe are defined in the libc.a library (correct me if I'm wrong), by doing arm-none-eabi-gcc -o hello hello.c libc.a but the outcome still results in errors:

libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x16): undefined reference to `_exit'
libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x10): undefined reference to `_read'
collect2: error: ld returned 1 exit status

我真的不确定为什么即使我已将库链接到应用程序,程序仍然无法识别标准函数.如果有人有理由解释为什么,或者我如何解决这个问题的解决方案,我将不胜感激.

I'm really unsure as to why the program still does not recognize the standard functions even though I've linked the library to the application. If anyone has a reason as to why, or a solution as to how I can fix this problem, I would be very grateful.

更新

我已经从这里下载了 glibc 库.我已经从在 newlib-2.1.0/libgloss/arm 中找到的 syscalls.c 库编译并创建了一个静态库,当我将该库链接到我的应用程序代码,我仍然遇到相同的错误.

I've downloaded the glibc library from here. I've compiled and created a static library from the syscalls.c library that I found in newlib-2.1.0/libgloss/arm and when I link the library to my application code, I still get the same error.

推荐答案

尝试执行这个:

arm-none-eabi-gcc --specs=rdimon.specs -lgcc -lc -lm -lrdimon -o hello hello.c

您的工具包似乎提供了 librdimon.a,这是一个提供基本标准 C 函数的库.

Your toolkit seems to provide the librdimon.a, a library which provides the basic standard C functions.

这篇关于使用 arm-none-eabi-gcc 编译并链接库 liba.a 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆