exit.c:(.text+0x18): 使用 arm-none-eabi-gcc 时对 `_exit' 的未定义引用 [英] exit.c:(.text+0x18): undefined reference to `_exit' when using arm-none-eabi-gcc
问题描述
我是微控制器领域的新手.我需要移植一个 IDE,它正在为 AVR 微控制器编译程序,以便为 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-GCC\bin\arm-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_Files\Blink_arm.cpp.elf <Dir_name>\Build_Files\Blink_arm.cpp.o <Dir_name>\Build_Files\core.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.2\libc.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® 编译器工具链 4.1 版表明:
ARM® Compiler toolchain Version 4.1 indicates:
半主机是一种机制,它使运行在 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屋!