This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Undefined reference to `_exit' when building blinky

There is a similar case where the user mentions that he fixed his issue by "changing the compiler" with no further explanations.

https://devzone.nordicsemi.com/f/nordic-q-a/30208/exit-c-text-exit-0x16-undefined-reference-to-_exit


I have the same issue.  How do I change the compiler?  To what?

  • Attaching my logs

    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: C:/gnuarmemb/bin/arm-none-eabi-gcc.exe 
    Build flags: 
    Id flags:  
    
    The output was:
    1
    c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x2c): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status
    
    
    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: C:/gnuarmemb/bin/arm-none-eabi-gcc.exe 
    Build flags: 
    Id flags:  
    
    The output was:
    1
    c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x2c): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status
    
    
    
    The target system is: Generic - 2.3.0 - arm
    The host system is: Windows - 10.0.17134 - AMD64
    Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
    Compiler: C:/gnuarmemb/bin/arm-none-eabi-gcc.exe 
    Build flags: 
    Id flags: -c 
    
    The output was:
    0
    
    
    Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o"
    
    The C compiler identification is GNU, found in "C:/Users/mario.raposo/ncs/zephyr/samples/basic/blinky/build_thingy91_nrf9160ns/CMakeFiles/3.18.4/CompilerIdC/CMakeCCompilerId.o"
    
    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
    Compiler: C:/gnuarmemb/bin/arm-none-eabi-gcc.exe 
    Build flags: 
    Id flags: -c 
    
    The output was:
    0
    
    
    Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o"
    
    The CXX compiler identification is GNU, found in "C:/Users/mario.raposo/ncs/zephyr/samples/basic/blinky/build_thingy91_nrf9160ns/CMakeFiles/3.18.4/CompilerIdCXX/CMakeCXXCompilerId.o"
    
    Checking whether the ASM compiler is GNU using "--version" matched "(GNU assembler)|(GCC)|(Free Software Foundation)":
    arm-none-eabi-gcc.exe (GNU Tools for Arm Embedded Processors 8-2019-q3-update) 8.3.1 20190703 (release) [gcc-8-branch revision 273027]
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    

  • Hi I am facing similar issue, can you help in providing solution.

  • Hi Chandra,

    Are you facing the exact same issue? If not please create a new Devzone question with your specs and work environment.

    The _exit "error" is just an induction that one or serval of the the compiling id failed and is not in it self a cause of worry as it will show the same error when it is successfully building a project.

    I included a CMakeError.log from a project that successfully builds.

    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: C:/gnuarmemb/bin/arm-none-eabi-gcc.exe 
    Build flags: 
    Id flags:  
    
    The output was:
    1
    c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x2c): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status
    
    
    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: C:/gnuarmemb/bin/arm-none-eabi-gcc.exe 
    Build flags: 
    Id flags:  
    
    The output was:
    1
    c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/gnuarmemb/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x2c): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status


    Regards,
    Jonathan

Related