Linker error: The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
JS_4155161
Level 1
Level 1

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();

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I did some study about this error, and found that this error often happens when you use atof() or some functions related to the float.

So, I changed Build Settings > ARM GCC 5.4-2016... > Linker > General > Use newlib-nano Float Formatting to "True"

001-Build-Linker-option.JPG

Then your project could be compiled.

002-compiled.JPG

moto

View solution in original post

0 Likes
2 Replies
RaAl_264636
Level 6
Level 6
50 sign-ins 25 sign-ins 10 solutions authored

Hi JS,

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.

Regards

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I did some study about this error, and found that this error often happens when you use atof() or some functions related to the float.

So, I changed Build Settings > ARM GCC 5.4-2016... > Linker > General > Use newlib-nano Float Formatting to "True"

001-Build-Linker-option.JPG

Then your project could be compiled.

002-compiled.JPG

moto

0 Likes