Linker error, undefined reference to `_sbrk'

‘Invoking: ARM Windows GCC C Linker (Sourcery Lite Bare)’
arm-none-eabi-gcc -T"D:\M66_OpenCPU_GS3_SDK_V2.3_Eclipse\M66_OpenCPU_GS3_SDK_V2.3_Eclipse\libs\gcc\linkscript.ld" -L"D:\M66_OpenCPU_GS3_SDK_V2.3_Eclipse\M66_OpenCPU_GS3_SDK_V2.3_Eclipse\libs\gcc" -L"C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI\arm-none-eabi\lib\thumb" -L"C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI\lib\gcc\arm-none-eabi\4.7.2\thumb" -Wl,-Map,“APPGS3MDM32A01.map” -Rbuild -march=armv5te -mthumb-interwork -mfloat-abi=soft -g3 -o “APPGS3MDM32A01.elf” ./ril/src/ril_alarm.o ./ril/src/ril_atResponse.o ./ril/src/ril_audio.o ./ril/src/ril_bluetooth.o ./ril/src/ril_custom.o ./ril/src/ril_dtmf.o ./ril/src/ril_ftp.o ./ril/src/ril_http.o ./ril/src/ril_init.o ./ril/src/ril_location.o ./ril/src/ril_network.o ./ril/src/ril_ntp.o ./ril/src/ril_sim.o ./ril/src/ril_sms.o ./ril/src/ril_system.o ./ril/src/ril_telephony.o ./ril/src/ril_urc.o ./ril/src/ril_util.o ./example/Example_gps_iic.o ./example/example_adc.o ./example/example_alarm.o ./example/example_audio.o ./example/example_bluetooth.o ./example/example_call.o ./example/example_clk.o ./example/example_csd.o ./example/example_download_epo.o ./example/example_dtmf.o ./example/example_eint.o ./example/example_file.o ./example/example_float_math.o ./example/example_fota_ftp.o ./example/example_fota_http.o ./example/example_ftp.o ./example/example_gpio.o ./example/example_http.o ./example/example_iic.o ./example/example_location.o ./example/example_memory.o ./example/example_multitask.o ./example/example_multitask_port.o ./example/example_pwm.o ./example/example_sms.o ./example/example_spi.o ./example/example_system.o ./example/example_tcp_demo.o ./example/example_tcpclient.o ./example/example_tcpserver.o ./example/example_time.o ./example/example_timer.o ./example/example_transpass.o ./example/example_udpclient.o ./example/example_udpserver.o ./example/example_watchdog.o ./example/nema_pro.o ./example/utility.o ./custom/fota/src/fota_ftp.o ./custom/fota/src/fota_http.o ./custom/fota/src/fota_http_code.o ./custom/fota/src/fota_main.o ./custom/config/custom_sys_cfg.o ./custom/config/sys_config.o ./custom/flash.o ./custom/gnss.o ./custom/gpio.o ./custom/gprs.o ./custom/main.o ./custom/sms.o ./custom/socket.o -lapp_start -lm -lc -lcs3 -lgcc
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI\arm-none-eabi\lib\thumb\libc.a(lib_a-sbrkr.o): In function _sbrk_r': sbrkr.c:(.text+0xc): undefined reference to _sbrk’
collect2.exe: error: ld returned 1 exit status
make: *** [APPGS3MDM32A01.elf] Error 1

I’m getting this error while compiling my code

you use some string function from STD library as sprintf()

for some std function, the application may crash without malloc() free()

void *_sbrk(int incr) { return (void *)-1; }

So what to do now sir

don’t use std or implement malloc() free()

or put this and test
void *_sbrk(int incr) { return (void *)-1; }

1 Like

hello sir @WizIO,

C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-abort.o): In function abort': abort.c:(.text+0xa): undefined reference to _exit’
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-signalr.o): In function _kill_r': signalr.c:(.text+0xe): undefined reference to _kill’
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-signalr.o): In function _getpid_r': signalr.c:(.text+0x2e): undefined reference to _getpid’
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-writer.o): In function _write_r': writer.c:(.text+0x10): undefined reference to _write’
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-closer.o): In function _close_r': closer.c:(.text+0xc): undefined reference to _close’
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-fstatr.o): In function _fstat_r': fstatr.c:(.text+0xe): undefined reference to _fstat’
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-isattyr.o): In function _isatty_r': isattyr.c:(.text+0xc): undefined reference to _isatty’
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-lseekr.o): In function _lseek_r': lseekr.c:(.text+0x10): undefined reference to _lseek’
C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/lib/thumb/libc.a(lib_a-readr.o): In function _read_r': readr.c:(.text+0x10): undefined reference to _read’
make.exe[1]: *** [build\gcc/APPGS3MDM32A01.elf] Error 1
make: *** [all] Error 2

I am getting this type of error while porting littlefs source code to quectel m66 sdk.
what exactly this error means ?
when this error occurs?
Can you please provide some pointers, to which standard functions might be using these.

Thanking you in advance.

hi
you use std libs… use Quectel API or implement missing functions

1 Like