exit.c:(.text+0x18): 使用 arm-none-eabi-gcc 时未定义对“_exit"的引用 [英] exit.c:(.text+0x18): undefined reference to `_exit' when using arm-none-eabi-gcc

查看:27
本文介绍了exit.c:(.text+0x18): 使用 arm-none-eabi-gcc 时未定义对“_exit"的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是微控制器领域的新手.我需要移植一个为 AVR 微控制器编译程序的 IDE,以便为 ARM 微控制器编译程序.我刚刚将编译器从 AVR 替换为 ARM,并按照某人的说法添加了一些选项.以下是命令:

I'm new to the field of microcontrollers. I need to port an IDE which is compiling programs for AVR microcontrollers to compile programs for ARM microcontrollers. I have just replaced the compiler from AVR to ARM and added some options as told by someone. The following is the command:

ARM-GCCinarm-none-eabi-gcc -O0 -ffunction-sections -Wall -std=gnu99 -mfloat-abi=soft 
-Wa,-adhlns="$@.lst" -fmessage-length=0 -mcpu=cortex-m0 -mthumb -g3 -gdwarf-2 -Wl,
--gc-sections -o <Dir_name>Build_FilesBlink_arm.cpp.elf  <Dir_name>Build_FilesBlink_arm.cpp.o <Dir_name>Build_Filescore.a 
-L<Dir_name>Build_Files -lm 

当我执行它时,我得到以下错误:

When I execute it I get the follwing error:

tools/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.6.2libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text+0x18): undefined reference to `_exit'  
collect2: ld returned 1 exit status

我可以就这个错误是什么以及如何解决它获得一些帮助.而且我不知道命令行中的那些选项指定了什么.

May I get some help on what is this error and how can I solve it. And also I don't know what those options in the command line specify.

推荐答案

在一台机器/架构中使用 arm-none-eabi-gcc 编译文件以将其加载到 ARM 目标时会发生这种情况机器.很可能您没有使用半主机,您想重新定位.

This happens when compiling a file with arm-none-eabi-gcc in one machine/architecture to load it in an ARM target machine. Most probably you are not making use of semihosting, you want to retarget.

ARM® Compiler 工具链版本 4.1 表示:

ARM® Compiler toolchain Version 4.1 indicates:

Semihosting 是一种机制,它使运行在 ARM 目标上的代码能够进行通信和在运行调试器的主机上使用输入/输出工具.

Semihosting is a mechanism that enables code running on an ARM target to communicate and use the Input/Output facilities on a host computer that is running a debugger.

来自工具链的 readme.txt(在文件夹 .../gcc-arm-none-eabi-VERSION/share/doc/gcc-arm-none-eabi 下):

From the toolchain's readme.txt (under folder .../gcc-arm-none-eabi-VERSION/share/doc/gcc-arm-none-eabi):

** 非半托管/重定向

** non-semihosting/retarget

如果您使用重定向,则链接如下:$ arm-none-eabi-gcc --specs=nosys.specs $(OTHER_LINK_OPTIONS)

If you are using retarget, linking like: $ arm-none-eabi-gcc --specs=nosys.specs $(OTHER_LINK_OPTIONS)

对我来说 --specs=nosys.specs 已经足够了 ;)

For me --specs=nosys.specs was enough ;)

这篇关于exit.c:(.text+0x18): 使用 arm-none-eabi-gcc 时未定义对“_exit"的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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