与臂无 - EABI-GCC编译错误Hello World程序Ç [英] Error compiling hello world program C with arm-none-eabi-gcc

查看:568
本文介绍了与臂无 - EABI-GCC编译错误Hello World程序Ç的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译在C Hello World程序在Linux 64位计算机上。我使用的是ARM的交叉编译我的应用程序装载到ARM处理器。然而,使用编译code当臂无 - EABI - 海合会-o你好的hello.c 我收到了一系列错误的:

I am trying to compile a hello world program in C on a Linux 64-bit machine. I am using an ARM cross compiler to load my application onto an ARM processor. However, when compiling the code using arm-none-eabi-gcc -o hello hello.c I get a series of errors:

/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o):在功能上退出:
  。exit.c中:( text.exit + 0x2C)设置:未定义引用
_exit
  /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o):在功能上 _sbrk_r':
  sbrkr.c :( text._sb​​rk_r +为0x18):未定义引用
_sbrk
  /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o):在功能上 _write_r':
  writer.c :( text._write_r + 0x20的):未定义引用
_write
  /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o):在功能上 _close_r':
  closer.c :( text._close_r +为0x18):未定义引用
_close
  /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o):在功能上 _fstat_r':
  。fstatr.c :( text._fstat_r + 0x1C处):未定义引用
_fstat
  /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o):在功能上 _isatty_r':
  isattyr.c :( text._isatty_r +为0x18):未定义引用
_isatty
  /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o):在功能上 _lseek_r':
  lseekr.c :( text._lseek_r + 0x20的):未定义引用
_lseek
  /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o):在功能上 _read_r':
  readr.c :( text._read_r + 0x20的):未定义引用
_read'
  collect2:错误:LD返回1退出状态

/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function exit': exit.c:(.text.exit+0x2c): undefined reference to_exit' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function _sbrk_r': sbrkr.c:(.text._sbrk_r+0x18): undefined reference to_sbrk' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function _write_r': writer.c:(.text._write_r+0x20): undefined reference to_write' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function _close_r': closer.c:(.text._close_r+0x18): undefined reference to_close' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function _fstat_r': fstatr.c:(.text._fstat_r+0x1c): undefined reference to_fstat' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function _isatty_r': isattyr.c:(.text._isatty_r+0x18): undefined reference to_isatty' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function _lseek_r': lseekr.c:(.text._lseek_r+0x20): undefined reference to_lseek' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function _read_r': readr.c:(.text._read_r+0x20): undefined reference to_read' collect2: error: ld returned 1 exit status

当我尝试做编译:臂无 - EABI-GCC -c hello.c的,它创建了一个对象,code hello.o 这告诉我,编译器运行正常。

When I try compiling by doing: arm-none-eabi-gcc -c hello.c, it creates an object code hello.o which tells me that the compiler runs fine.

可能有人或许告诉我为什么我的编译返回这样的错误吗?

Could someone perhaps tell me why my compilation is return such errors please?

更新

我现在认识到C运行时库不包含在汇编。有谁知道我需要在编译或如何库如printf例如链接到能够使用标准功能的任何选项?

I realize now that the C runtime library isn't included in the compilation. Does anyone know of any options I need to include in the compilation or how to link the library to be able to use standard functions such as printf for example?

推荐答案

我应该在MCU芯片做一个printf字符串,因为没有控制台?这就是正在发生的事情。 libc的需要低级功能是依赖于平台,不应包含在libc中。

What should the MCU chip do with a printf string since there is no console? That's what is happening. libc needs low level functions that is platform dependent and shall not be included in the libc.

您需要一个retarget.c中或定义所有这些失踪的符号和正确的重新定位printf的输出,你必须从芯片的外部访问串口线syscalls.c文件。

You need a retarget.c or a syscalls.c file that defines all these missing symbols and properly retarget the printf output to a serial line that you have access from the outside of the chip.

我强烈建议您使用 yagarto 的工具包,他们提供了一个的有什么必要对libc的链接时,建一个项目,你正在做的syscall.c 文件。

I strongly recommend you to use the yagarto toolkit, they provide a syscall.c file with what's necessary to build a project when linking against libc, as you are doing.

如果你想尝试的短路径,包括 syscall.c 文件到您的项目,重新设定它的内部功能,以满足您的需求。

If you want to try the short path, include the syscall.c file to your project and reprogram its functions internals to suit your needs.

在单片机世界链接到的libc中的裸gcc工具不适合初学者。我的建议是始终要遵循循序渐进yagarto的教程。

Linking bare gcc toolchain against libc in the microcontroller world is not for beginners. My recommendation is always to follow step by step yagarto's tutorials.

这篇关于与臂无 - EABI-GCC编译错误Hello World程序Ç的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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