undefined reference to `_sbrk' / `_write' / `_close' / `_exit' (newlib stubs)
newlib needs a few system-call stubs on bare metal, and none were provided.
undefined reference to `_sbrk'undefined reference to `_write'undefined reference to `_exit'newlib syscalls Meaning
Functions such as malloc, printf and exit call _sbrk, _write, _close, _exit. On a microcontroller you must implement them, or link --specs=nosys.specs.
Common causes
- No syscalls file in the project
- Missing
--specs=nosys.specs - Using malloc/printf without retargeting
- nano.specs without stubs
⚡ Quick fix
- Add
--specs=nosys.specsto the link flags - Implement
_writeand_sbrkfor your UART and heap - Avoid malloc on small targets
Detailed fix by platform
GCC
arm-none-eabi-gcc ... --specs=nano.specs --specs=nosys.specs
How to diagnose
- Specs — nosys/nano linked?
- Stubs — Implemented?
- Use — malloc/printf?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in C/C++
- Bus error C/C++: Bus error (core dumped) — SIGBUS from misaligned access or a bad memory-mapped file
- AddressSanitizer: heap-buffer-overflow C/C++: ==ERROR: AddressSanitizer: heap-buffer-overflow on address — READ/WRITE of size N
- AddressSanitizer: heap-use-after-free C/C++: ==ERROR: AddressSanitizer: heap-use-after-free on address — memory used after delete/free
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 2 Dec 2026