exit.c:(.text+0x18): undefined reference to `_exit' when using arm-none-eabi-gcc

前端 未结 3 537
小蘑菇
小蘑菇 2020-11-29 01:37

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 ju

相关标签:
3条回答
  • 2020-11-29 02:16

    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 toolchain Version 4.1 indicates:

    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.

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

    ** non-semihosting/retarget

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

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

    0 讨论(0)
  • 2020-11-29 02:24

    Use --specs=nosys.specs:

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

    Reference:

    • ARM Options
    • GNU Tools for ARM Embedded Processors
    0 讨论(0)
  • 2020-11-29 02:38

    I had the same problem. The solution was as follows:

    • Add options -ffreestanding -flto into compiler call line.
    • And add options -flto -ffreestanding -nostdlib into linker call line.
    0 讨论(0)
提交回复
热议问题