Undefined reference to _sbrk

This helps:

-mcpu=cortex-m4 -mthumb -specs=nano.specs -specs=nosys.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard

The important switches "seem" to be:

-specs=nano.specs -specs=nosys.specs


The problem has little to do with _sbrk itself, but rather your attempt to invoke the linker directly, bypassing the compiler driver. Instead, use the gcc command to invoke the linker and the -Wl,-linkeroptionhere syntax to pass extra options to the linker.

One possible solution, if you must invoke the linker yourself.. Try repeating both libc.a and libgcc.a a second time at the end of the command line. There's also some "as group" linker option you could use to achieve this but I don't know it right off.


I was having the same problem, and adding those to the linker flags helped:

-specs=nano.specs -specs=nosys.specs

Also, just with the nosys.specs fixed the issue, but the code size was a lot bigger.

Tags:

C

Gcc

Arm

Sbrk