undefined reference to `_exit

Rohit Arul Raj rohitarulraj@gmail.com
Mon Dec 19 12:10:00 GMT 2011


On Tue, Dec 13, 2011 at 3:55 PM, Can Finner <can.finner@gmail.com> wrote:
>>
>> While building newlib, i had expected the following libraries to be
>> generated: libc.a, libg.a (a debugging-enabled libc), and libm.a.
>> But if seems there is no difference between 'libc.a' and 'libg.a'.
>> Based on the flags, either both are generated with debug info or both
>> without debug info.
>>
>> Also, looking the build logs and makefile, it seems 'libg.a' is a copy
>> of 'libc.a'.
>>
>> libc.a: libc/libc.a libm.a
>>        rm -rf libc.a libg.a tmp
>>        mkdir tmp
>>        cd tmp; \
>>         $(AR) x ../libm.a $(MATHOBJS_IN_LIBC) ; \
>>         $(AR) x ../libc/libc.a ; \
>>         $(AR) $(AR_FLAGS) ../$@ *.o
>>        $(RANLIB) libc.a
>>        ln libc.a libg.a >/dev/null 2>/dev/null || cp libc.a libg.a
>> ------------------------(A)
>>        rm -rf tmp
>>
>> My requirement is to build libc.a [without debug info] and libg.a
>> [with debug info] and update the gcc spec [#define LIB_SPEC] file to
>> choose the required libraries automatically.
>>
> Hi, I also got a question on this.
> I built cross toolchain for arm-none-eabi with newlib.
> for c++ programs, the below command:
> arm-none-eabi-g++ hello.cc --specs=rdimon.specs -lc -lrdimon -lc -o a.out
>
> complains that:
> --------------------------------
> libc.a(lib_a-exit.o): In function `exit':
> exit.c:(.text+0x2c): undefined reference to `_exit'
> libc.a(lib_a-abort.o): In function `abort':
> abort.c:(.text+0x10): undefined reference to `_exit'
> libc.a(lib_a-signalr.o): In function `_kill_r':
> signalr.c:(.text+0x1c): undefined reference to `_kill'
>
> whle below command is ok;
> arm-none-eabi-g++ hello.cc --specs=rdimon.specs -lg -lrdimon -lg -o a.out
>
> BTW, the hello.cc is just a c++ hello world program.
>
> Thanks
> --
> Regards.

Please post a new thread for different queries.

In your case, you are missing the system call library which you are
supposed to provide (even empty routines or routines with minimal
functionality) to allow your programs to link with the subroutines in
libc.a

The list of sub-routines to be provided are available in:
http://sourceware.org/newlib/libc.html#Syscalls

Regards,
Rohit



More information about the Newlib mailing list