使用CMake鏈接我的STM32項目時遇到了困難。生成的鏈接命令是:使用arm-none-eabi-gcc,newlib和cmake鏈接C/C++ STM32項目
/Users/jeremy/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fdata-sections -ffunction-sections -g -Og -gdwarf-2 -MMD -MP -std=c++11 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -specs=nano.specs -T/Users/jeremy/stm32l432kc_freertos_template/STM32L432KCUx_FLASH.ld -Wl,-Map=target.map,--cref -Wl,--gc-sections
< ... lots of .o files here ...>
-o stm32l432kc_freertos -lc -lm -lnosys
不幸的是,我得到了兩組錯誤。第一個是:
arm-none-eabi/bin/ld: warning: cannot find entry symbol arch_paths_first; defaulting to 0000000008000190
這表明不存在條目的象徵,但在LD文件的第一行代碼是:ENTRY(Reset_Handler)
。符號Reset_Handler
在鏈接文件startup_stm32l432xx.s
中定義。
第二組的錯誤涉及STDLIB:
/Users/jeremy/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/libg_nano.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'
/Users/jeremy/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/libg_nano.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid'
,這是爲了通過連接-lnosys
來解決,但鏈接似乎忽略了。
本質上,鏈接器似乎忽略了LD文件中的一些指令,並忽略了一些已通過的標誌。我意識到這可能是我做錯了,但我看不到它是什麼。
如果我加-specs=nosys.specs
後兩個錯誤消失了,但這不應該是必要的嗎?有人能幫我理解這裏出了什麼問題嗎?