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:
- ORB-SLAM3 Compile Error: recipe for target ‘CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o‘ failed
- Eclipse Godson Error: Makefile:recipe for target ‘clean‘ failed
- [Solved] ROS fatal error: alsa/asoundlib. h: There is no such directory or file
- Clion new method shows undefined reference to solution
- [Solved] error adding symbols: File in wrong format collect2: error: ld returned 1 exit status
- VSCode Error: collect2.exe:error:1d returned 1 exit status [How to Solve]
- [Solved] igb Compile Error: igb_main.c:10044:7: error: implicit declaration of function ‘isdigit’
- GCC Error:(.text+0x24): undefined reference to `main‘collect2: error: ld returned 1 exit status [Solved]
- Ubutnu Qt Unable to start process Error: “make“ -f ‘ /usr/bin/ld: cannot find -lGL collect2: error: ld returned 1 exit sta
- [Solved] PCL Compile Error: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>:: XXX
- [Solved] C++ error: undefined reference to `xxx‘
- Error:invalid new-expression of abstract class type XXX [How to Solve]
- [PX4 Bug] make px4_sitl gazebo Error: CMake Error: The following variables are used in this project
- [Solved] IOS Error: Command MergeSwiftModule failed with a nonzero exit code
- Visual Studio 2012 error C4996: ‘scanf’: This function or variable may be unsafe.
- Dev C++ Error: error: ld returned 1 exit status [How to Solve]
- [Solved] target_link_libraries error: a missing vtable usually means the first non-inline virtual member function has no definition.
- [Solved] latex Compile llncs2e reference error locally
- [jv-convert] Error 1, [all-recursive] Error 1 (How to Solve)
- [Solved] VUE Use Filters Error: [Vue warn]: Error in render: “TypeError: Cannot read property ‘toFixed’ of undefined”