exit.c:(.text+0x18):使用arm-none-eabi-gcc时未定义的“_exit”引用。

时间:2022-08-30 15:29:09

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:

我是微控制器领域的新手。我需要移植一个IDE来编译AVR微控制器的程序来编译ARM微控制器的程序。我刚刚替换了从AVR到ARM的编译器,并添加了一些选项。下面是命令:

\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.

我能得到一些帮助吗?这个错误是什么,我怎么解决?我也不知道命令行中那些选项是什么。

2 个解决方案

#1


41  

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 -none-eabi-gcc的文件时,就会发生这种情况,从而将其加载到ARM目标机器中。很可能你没有使用半托管,你想要重新定位。

ARM® Compiler toolchain Version 4.1 indicates:

手臂®4.1版本的编译器工具链表示:

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.

半托管是一种机制,它允许在ARM目标上运行代码来通信,并在运行调试器的主机上使用输入/输出设备。

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

工具链的自述。txt(在文件夹…/ gcc-arm-none-eabi-VERSION /分享/ doc / gcc-arm-none-eabi):

** non-semihosting/retarget

* * non-semihosting / gdp8 %

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

如果您使用的是retarget,链接如下:$ arm-none-eabi-gcc—specs=nosys。规格(OTHER_LINK_OPTIONS美元)

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

对我来说,规格=好管闲事。规格是足够的,)

#2


26  

Use --specs=nosys.specs:

使用——规格= nosys.specs:

arm-none-eabi-gcc --specs=nosys.specs $(OTHER_LINK_OPTIONS)

Reference:

参考:

#1


41  

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 -none-eabi-gcc的文件时,就会发生这种情况,从而将其加载到ARM目标机器中。很可能你没有使用半托管,你想要重新定位。

ARM® Compiler toolchain Version 4.1 indicates:

手臂®4.1版本的编译器工具链表示:

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.

半托管是一种机制,它允许在ARM目标上运行代码来通信,并在运行调试器的主机上使用输入/输出设备。

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

工具链的自述。txt(在文件夹…/ gcc-arm-none-eabi-VERSION /分享/ doc / gcc-arm-none-eabi):

** non-semihosting/retarget

* * non-semihosting / gdp8 %

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

如果您使用的是retarget,链接如下:$ arm-none-eabi-gcc—specs=nosys。规格(OTHER_LINK_OPTIONS美元)

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

对我来说,规格=好管闲事。规格是足够的,)

#2


26  

Use --specs=nosys.specs:

使用——规格= nosys.specs:

arm-none-eabi-gcc --specs=nosys.specs $(OTHER_LINK_OPTIONS)

Reference:

参考: