Background: When cortex_m3 uses FreeRTOS to enable the running time statistics function.
Compilation error during compilation:
/Data/user_ Home//build_ Tools/GCC arm none eabi-/bin// Lib/gcc/arm-none-eabi/6.2.1/../../../../..// Arm-none-eabi/lib/thumb/v7-m/libc A (lib_a-sbrkr.o): in function`_ Sbrk_ R’:
Sbrkr c: (.Text.\u sbrk_r+0xc): undefined reference to`_ Sbrk’
Collect2: error: LD returned 1 exit status
Makefile:155: recipe for target’all’failed
Make: * * * [all] error 1
Cause: by default, arm GCC uses startfiles, which results in link compilation failure when calling some functions (malloc, free, sprintf…) that are not implemented at the bottom.
Promotion: if the compiler reports Error: undefined reference to `_sbrk’ `_read’ `_write’ `_lseek’ `_isatty’ `_fstat’ , it is the same reason.
Solution:
Method 1: if the project does not need these functions, find the direct mask function.
Method 2: once and for all. The link fails because these functions are not implemented, so you can rewrite these underlying functions or add library files with these functions, such as libnosys a. Add compilation parameter —specs=nosys.specs can be used.
After adding, if the compiler reports the following errors:
/Data/user_ Home/ /build_ Tools/GCC arm none eabi-/bin// Lib/gcc/arm-none-eabi/6.2.1/../../../../..// Arm-none-eabi/lib/thumb/v7-m/libnosys A (sbrk.o): in function`_ Sbrk’:
Sbrk c: (.Text.\u sbrk+0x18): undefined reference to `end’
Collect2: error: LD returned 1 exit status
Makefile:155: recipe for target’all’failed
Make: * * * [all] error 1
This is because the ‘end’ symbol is not defined in the .lds linker script, so find the project’s xx.lds file to set that script for the heap location, e.g.
.heap : { . = ALIGN(4); __HEAP_START = .; . += 0x2000; __HEAP_MAX = .; end = __HEAP_MAX; PROVIDE(end = .); } > ram
Read More:
- Clion new method shows undefined reference to solution
- ST-LINK Download Program Error: flash download failed – ‘cortex m4‘
- [Solved] Qt Error: undefined reference to xxxxx
- [Solved] FreeRTOS Debug Error: Error: L6218E: Undefined symbol xQueueCreateCountingSemaphore
- error: undefined reference to `calculate()` [How to Solve]
- [Solved] C++ error: undefined reference to `xxx‘
- [Solved] Compile Error: undefined reference to `google::FlagRegisterer::FlagRegisterer
- GCC Error:(.text+0x24): undefined reference to `main‘collect2: error: ld returned 1 exit status [Solved]
- [Solved] PCL Compile Error: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>:: XXX
- [Solved] QT error: error: undefined reference to ` VTable`
- C++Qt development – Qtsocket programming error: undefined reference to `_imp__WSAStartup
- [Solved] VScode Error: undefined reference to ‘WinMain’ collect2.exe: error: ld returned 1 exit status
- [Solved] QT Error: error: undefined reference to `GameModel::~GameModel()’
- [Solved] Compile the program error: undefined reference to `cv::dnn::dnn4_v20210301::Net::~Net()‘
- [Solved] Error: Flash Download failed – “Cortex-M3“
- [Solved] Error:Flash Download failed -“Cortex-M3”
- M1 MacBook cannot use pip to install pandas [How to Solve]
- How to Solve m_gshhs_i Error
- How to Solve Xcode M1 simulator Error
- How to Solve Kotlin unresolved reference error