I am completely puzzled by the above error that I get in PSOC creator 4.2. When I call the function processCommand() from main.c the linker throws an error. The function processCommand() is defined in console.c and its function prototype is in console.h. I Include console.h in main.c.
I get the following error message:
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.
I have been struggling with this and have tried several solutions from this forum. Can anyone propose a solution? I have attached my project below.
To reproduce the error, uncomment line 34 in main.c, which is: processCommand();
Solved! Go to Solution.
I had the undefined reference to sbrk in the past, too. In your project, it's defined in Cm0Start.c as a 'weak' function. This means that the linker will use a different function with the same name if defined by you. However, depending on the linker settings, the optimization process will remove a weak function, even if it should be use. I solved those issue by setting a different optimization level for the Cm0Start.c file.