Undefined reference to `_exit' and friends

I'm not a compiler guy, so I don't know the correct resolution to this issue, but at least I can describe it. While working in C, I ran across a set of curious errors once I made a call to sprintf():

[...]/stdlib/abort.c:59: undefined reference to `_exit'
[...]/reent/signalr.c:53: undefined reference to `_kill'
[...]/reent/signalr.c:83: undefined reference to `_getpid'
[...]/reent/writer.c:49: undefined reference to `_write'
[...]/reent/closer.c:47: undefined reference to `_close'
[...]/reent/fstatr.c:55: undefined reference to `_fstat'
[...]/reent/isattyr.c:52: undefined reference to `_isatty'
[...]/reent/lseekr.c:49: undefined reference to `_lseek'
[...]/reent/readr.c:49: undefined reference to `_read'

Removing the calls to sprintf() got these errors to go away.

Stack Overflow suggests this thread, which pretty accurately describes my situation. The suggested solution is to compile with --specs=nosys.specs for reasons that kind of went over my head. I added the switch into C_API/buildsupport/common.mk in the recipe for pdex.elf (line 145 in the 1.12.0 SDK) and I was able to compile with no issue.

There may be other standard C functions that cause this to pop up. If all else fails, the above solution does appear to get around the issue without introducing any new ones.

1 Like