json_value.asm: No such file or directory

本文介绍了解决编译时遇到的错误——无法打开文件'json_writer.asm'的方法。主要提供了两种解决方案:一是调整jsoncpp项目的设置,禁用全程序优化;二是修改项目的汇编程序输出设置为无列表。

转自: http://blog.youkuaiyun.com/sdcxyz/article/details/11983657


链接提示:无法打开编译器生成的文件:“../../build/vs71/release/lib_json\json_writer.asm


解决方法:1:修改jsoncpp的项目设置  配置属性---全程序优化 为无全程序优化

              或者2:修改菜单---项目--属性---配置属性---c/c++---输出文件---汇编程序输出:无列表 


PS E:\stm\tim_servo> ninja -C build ninja: Entering directory `build' [1/6] Building C object CMakeFiles/tim_servo.dir/Core/Src/syscalls.c.obj FAILED: [code=1] CMakeFiles/tim_servo.dir/Core/Src/syscalls.c.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -std=gnu11 -MD -MT CMakeFiles/tim_servo.dir/Core/Src/syscalls.c.obj -MF CMakeFiles\tim_servo.dir\Core\Src\syscalls.c.obj.d -o CMakeFiles/tim_servo.dir/Core/Src/syscalls.c.obj -c E:/stm/tim_servo/Core/Src/syscalls.c E:/stm/tim_servo/Core/Src/syscalls.c:31:10: fatal error: sys/times.h: No such file or directory 31 | #include <sys/times.h> | ^~~~~~~~~~~~~ compilation terminated. [2/6] Building ASM object CMakeFiles/tim_servo.dir/startup_stm32f103xb.s.obj FAILED: [code=1] CMakeFiles/tim_servo.dir/startup_stm32f103xb.s.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -g -MD -MT CMakeFiles/tim_servo.dir/startup_stm32f103xb.s.obj -MF CMakeFiles\tim_servo.dir\startup_stm32f103xb.s.obj.d -o CMakeFiles/tim_servo.dir/startup_stm32f103xb.s.obj -c E:/stm/tim_servo/startup_stm32f103xb.s E:/stm/tim_servo/startup_stm32f103xb.s: Assembler messages: E:/stm/tim_servo/startup_stm32f103xb.s:28: Error: unknown pseudo-op: `.syntax' E:/stm/tim_servo/startup_stm32f103xb.s:29: Error: unknown pseudo-op: `.cpu' E:/stm/tim_servo/startup_stm32f103xb.s:30: Error: unknown pseudo-op: `.fpu' E:/stm/tim_servo/startup_stm32f103xb.s:31: Error: unknown pseudo-op: `.thumb' E:/stm/tim_servo/startup_stm32f103xb.s:59: Warning: .type pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:59: Error: junk at end of line, first unrecognized character is `R' E:/stm/tim_servo/startup_stm32f103xb.s:63: Error: no such instruction: `bl SystemInit' E:/stm/tim_servo/startup_stm32f103xb.s:66: Error: no such instruction: `ldr r0,=_sdata' E:/stm/tim_servo/startup_stm32f103xb.s:67: Error: no such instruction: `ldr r1,=_edata' E:/stm/tim_servo/startup_stm32f103xb.s:68: Error: no such instruction: `ldr r2,=_sidata' E:/stm/tim_servo/startup_stm32f103xb.s:69: Warning: `r3' is not valid here (expected `(%rsi)') E:/stm/tim_servo/startup_stm32f103xb.s:69: Error: expecting operand after ','; got nothing E:/stm/tim_servo/startup_stm32f103xb.s:70: Error: no such instruction: `b LoopCopyDataInit' E:/stm/tim_servo/startup_stm32f103xb.s:73: Error: no such instruction: `ldr r4,[r2,r3]' E:/stm/tim_servo/startup_stm32f103xb.s:74: Error: missing ']' E:/stm/tim_servo/startup_stm32f103xb.s:74: Error: too many memory references for `str' E:/stm/tim_servo/startup_stm32f103xb.s:75: Error: expecting operand after ','; got nothing E:/stm/tim_servo/startup_stm32f103xb.s:78: Error: too many memory references for `add' E:/stm/tim_servo/startup_stm32f103xb.s:79: Error: operand type mismatch for `cmp' E:/stm/tim_servo/startup_stm32f103xb.s:80: Error: no such instruction: `bcc CopyDataInit' E:/stm/tim_servo/startup_stm32f103xb.s:83: Error: no such instruction: `ldr r2,=_sbss' E:/stm/tim_servo/startup_stm32f103xb.s:84: Error: no such instruction: `ldr r4,=_ebss' E:/stm/tim_servo/startup_stm32f103xb.s:85: Warning: `r3' is not valid here (expected `(%rsi)') E:/stm/tim_servo/startup_stm32f103xb.s:85: Error: expecting operand after ','; got nothing E:/stm/tim_servo/startup_stm32f103xb.s:86: Error: no such instruction: `b LoopFillZerobss' E:/stm/tim_servo/startup_stm32f103xb.s:89: Error: number of operands mismatch for `str' E:/stm/tim_servo/startup_stm32f103xb.s:90: Error: expecting operand after ','; got nothing E:/stm/tim_servo/startup_stm32f103xb.s:93: Error: operand type mismatch for `cmp' E:/stm/tim_servo/startup_stm32f103xb.s:94: Error: no such instruction: `bcc FillZerobss' E:/stm/tim_servo/startup_stm32f103xb.s:97: Error: no such instruction: `bl __libc_init_array' E:/stm/tim_servo/startup_stm32f103xb.s:99: Error: no such instruction: `bl main' E:/stm/tim_servo/startup_stm32f103xb.s:100: Error: no such instruction: `bx lr' E:/stm/tim_servo/startup_stm32f103xb.s:101: Warning: .size pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:101: Error: junk at end of line, first unrecognized character is `R' E:/stm/tim_servo/startup_stm32f103xb.s:111: Error: junk at end of line, first unrecognized character is `,' E:/stm/tim_servo/startup_stm32f103xb.s:114: Error: no such instruction: `b Infinite_Loop' E:/stm/tim_servo/startup_stm32f103xb.s:115: Warning: .size pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:115: Error: junk at end of line, first unrecognized character is `D' E:/stm/tim_servo/startup_stm32f103xb.s:123: Error: junk at end of line, first unrecognized character is `,' E:/stm/tim_servo/startup_stm32f103xb.s:124: Warning: .type pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:124: Error: junk at end of line, first unrecognized character is `g' E:/stm/tim_servo/startup_stm32f103xb.s:125: Warning: .size pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:125: Error: junk at end of line, first unrecognized character is `g' E:/stm/tim_servo/startup_stm32f103xb.s:196: Warning: value 0xf108f85f truncated to 0xf85f E:/stm/tim_servo/startup_stm32f103xb.s:207: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:209: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:211: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:213: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:215: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:217: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:219: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:221: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:223: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:225: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:227: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:229: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:231: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:233: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:235: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:237: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:239: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:241: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:243: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:245: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:247: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:249: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:251: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:253: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:255: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:257: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:259: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:261: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:263: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:265: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:267: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:269: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:271: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:273: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:275: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:277: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:279: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:281: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:283: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:285: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:287: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:289: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:291: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:293: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:295: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:297: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:299: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:301: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:303: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:305: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:307: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:309: Error: unknown pseudo-op: `.thumb_set' [3/6] Building C object CMakeFiles/tim_servo.dir/Core/Src/main.c.obj FAILED: [code=1] CMakeFiles/tim_servo.dir/Core/Src/main.c.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -std=gnu11 -MD -MT CMakeFiles/tim_servo.dir/Core/Src/main.c.obj -MF CMakeFiles\tim_servo.dir\Core\Src\main.c.obj.d -o CMakeFiles/tim_servo.dir/Core/Src/main.c.obj -c E:/stm/tim_servo/Core/Src/main.c In file included from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:131, from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h:130, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h:27, from E:/stm/tim_servo/Core/Inc/stm32f1xx_hal_conf.h:238, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:29, from E:/stm/tim_servo/Core/Inc/main.h:30, from E:/stm/tim_servo/Core/Src/main.c:20: E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_SetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1738:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1738 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_GetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1753:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1753 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ C:\Users\Yeah\AppData\Local\Temp\ccIGZrQh.s: Assembler messages: C:\Users\Yeah\AppData\Local\Temp\ccIGZrQh.s:139: Error: no such instruction: `cpsid i' [4/6] Building C object cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj FAILED: [code=1] cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -std=gnu11 -MD -MT cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj -MF cmake\stm32cubemx\CMakeFiles\STM32_Drivers.dir\__\__\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c.obj.d -o cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj -c E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c In file included from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:131, from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h:130, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h:27, from E:/stm/tim_servo/Core/Inc/stm32f1xx_hal_conf.h:238, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:82: E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_SetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1738:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1738 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_GetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1753:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1753 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s: Assembler messages: C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s:105: Error: number of operands mismatch for `ds' C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s:111: Error: no such instruction: `isb 0xF' C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s:445: Error: number of operands mismatch for `ds' C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s:458: Error: number of operands mismatch for `ds' [5/6] Building C object cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c.obj FAILED: [code=1] cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -std=gnu11 -MD -MT cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c.obj -MF cmake\stm32cubemx\CMakeFiles\STM32_Drivers.dir\__\__\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c.obj.d -o cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c.obj -c E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c In file included from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:131, from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h:130, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h:27, from E:/stm/tim_servo/Core/Inc/stm32f1xx_hal_conf.h:238, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c:26: E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_SetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1738:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1738 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_GetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1753:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1753 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c: In function 'HAL_PWR_EnableWakeUpPin': E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c:386:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 386 | *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)ENABLE; | ^ E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c: In function 'HAL_PWR_DisableWakeUpPin': E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c:401:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 401 | *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)DISABLE; | ^ C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s: Assembler messages: C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:13: Error: no such instruction: `wfe' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:304: Error: no such instruction: `wfi' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:311: Error: no such instruction: `sev' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:314: Error: no such instruction: `wfe' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:317: Error: no such instruction: `wfe' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:359: Error: no such instruction: `wfi' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:366: Error: no such instruction: `sev' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:403: Error: no such instruction: `wfi' ninja: build stopped: subcommand failed.如何解决
最新发布
11-15
<think> 我们面对的问题是:在VSCode中使用ninja和CMake构建基于STM32F103xB的项目时,出现两个主要错误: 1. 找不到头文件 `sys/times.h` 2. 汇编文件中出现大量未知伪操作及指令错误 结合引用内容和STM32开发背景,分析如下: ### 问题分析 1. **`sys/times.h` 缺失问题**: - 该头文件属于POSIX标准,通常出现在Linux/Unix系统中。STM32是嵌入式ARM平台,没有操作系统支持,因此标准库可能不包含该文件。 - 可能原因:项目代码中错误地包含了该头文件,或者某个依赖库需要它(但STM32环境不提供)。 2. **汇编文件错误**: - 伪操作(如 `.section`, `.global`)是GNU汇编器(GAS)的语法,而STM32开发通常使用ARMCC(Keil)或GCC工具链。 - 错误原因:项目中的汇编文件可能是为GNU汇编器编写的,但当前构建工具链可能是ARMCC(Keil)或其兼容性不足。 ### 解决方案 #### 1. 解决 `sys/times.h` 缺失 - **定位引用位置**: 在项目中搜索 `#include <sys/times.h>`,确定哪些源文件依赖它。 ```bash grep -r "#include <sys/times.h>" . ``` - **替代方案**: 如果代码中确实需要计时功能,考虑使用STM32的硬件定时器(如TIM)代替。删除该头文件,并重写相关代码。 示例: ```c // 删除: #include <sys/times.h> // 使用HAL库的定时器 #include "stm32f1xx_hal.h" ``` #### 2. 汇编文件错误处理 - **检查工具链兼容性**: 确保使用的汇编器支持GNU汇编语法。STM32的GCC工具链(如`arm-none-eabi-gcc`)支持,但若使用Keil的ARMCC则可能不兼容。 - **解决方案A(推荐)**:切换到GCC工具链 1. 修改CMakeLists.txt,指定GCC编译器: ```cmake set(CMAKE_C_COMPILER arm-none-eabi-gcc) set(CMAKE_CXX_COMPILER arm-none-eabi-g++) set(CMAKE_ASM_COMPILER arm-none-eabi-gcc) ``` 2. 确保汇编文件扩展名为 `.S`(大写S),这样GCC会进行预处理。 - **解决方案B**:修改汇编语法以适配ARMCC 如果必须使用Keil工具链(如引用[1]所述混合使用VSCode和Keil),需将GAS语法转为ARMCC支持的语法: - 将 `.section .text` 改为 `AREA |.text|, CODE, READONLY` - 将 `.global main` 改为 `EXPORT main` - 伪操作参考:[ARM汇编指南](https://developer.arm.com/documentation/dui0473/m/armcc-assembler-reference) #### 3. 验证构建配置 确保CMake生成正确的构建文件: ```cmake # 示例:STM32F103xB的基本配置 set(MCU STM32F103xB) set(CPU cortex-m3) add_compile_definitions(STM32F103xB) include_directories( Core/Inc Drivers/STM32F1xx_HAL_Driver/Inc ) # 链接脚本 set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32F103C8Tx_FLASH.ld) # 添加汇编启动文件(注意语法兼容性) add_executable(${PROJECT_NAME}.elf Core/Startup/startup_stm32f103c8tx.s # 确保此文件语法正确 # ... 其他源文件 ) ``` #### 4. 参考引用中的关键点 - **引用[1]**:推荐仅用VSCode编辑,用Keil构建调试。若汇编问题复杂,可回归Keil构建,在VSCode中仅编辑代码[^1]。 - **引用[2]**:注意中断向量表偏移问题。若项目涉及IAP,检查`system_stm32f10x.c`中的`VECT_TAB_OFFSET`设置[^2]。 - **引用[3]**:C++混合编程需确保链接器兼容C++库(如`libstdc++`)[^3]。 ### 操作步骤总结 1. **移除`sys/times.h`**:搜索并删除或替换其功能。 2. **统一工具链**: - 方案A:全GCC工具链 → 修改CMakeLists.txt。 - 方案B:适配ARMCC → 重写汇编文件。 3. **检查启动文件**:确保`startup_stm32f103c8tx.s`语法与工具链匹配。 4. **构建测试**: ```bash # 清理重建 rm -rf build/ cmake -B build -G Ninja ninja -C build ``` §§相关问题§§ 1. 如何配置VSCode用于STM32开发(编辑+Keil构建)? 2. STM32启动文件(汇编)的语法差异如何解决? 3. 在嵌入式系统中如何替代POSIX时间功能? </think> ## 解决 VSCode 中构建 STM32F103xB 项目的编译错误 ### 问题分析 您的两个核心问题源于工具链配置不兼容: 1. **找不到 sys/times.h**:POSIX 头文件在裸机嵌入式系统中不可用 2. **汇编文件伪操作错误**:GCC 汇编器与 ARMCC 语法不兼容 ### 解决方案 #### 1. 解决 `sys/times.h` 缺失问题 ```cmake # 在 CMakeLists.txt 中添加以下配置 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__weak=__attribute__((weak))") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__packed=__attribute__((__packed__))") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSTM32F103xB") ``` **替代 POSIX 时间函数**: ```c // 替换 #include <sys/times.h> #include "stm32f1xx_hal.h" uint32_t get_system_ticks() { return HAL_GetTick(); // 使用 HAL 库的时间函数 } ``` #### 2. 解决汇编文件错误 (关键步骤) ```cmake # 指定正确的汇编器并禁用预处理 set(CMAKE_ASM_COMPILER arm-none-eabi-gcc) set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -x assembler-with-cpp") ``` **修复启动文件语法** (`startup_stm32f103xb.s`): ```armasm ; 将 GNU 语法转为 ARMCC 兼容语法 .syntax unified ; 改为: THUMB .cpu cortex-m3 ; 改为: PRESERVE8 .type Reset_Handler, %function ; 改为: EXPORT Reset_Handler [WEAK] ``` #### 3. 完整工具链配置 ```cmake # CMakeLists.txt 关键配置 set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_C_COMPILER arm-none-eabi-gcc) set(CMAKE_CXX_COMPILER arm-none-eabi-g++) set(CMAKE_ASM_COMPILER arm-none-eabi-gcc) # 添加芯片特定定义 add_compile_definitions(STM32F103xB USE_HAL_DRIVER) # 包含标准外设库路径 include_directories( Drivers/CMSIS/Include Drivers/STM32F1xx_HAL_Driver/Inc ) ``` #### 4. VSCode 集成配置 (`.vscode/settings.json`) ```json { "cmake.generator": "Ninja", "cmake.buildDirectory": "${workspaceFolder}/build", "C_Cpp.default.includePath": [ "${workspaceFolder}/Drivers/CMSIS/Include", "${workspaceFolder}/Drivers/STM32F1xx_HAL_Driver/Inc" ], "C_Cpp.intelliSenseMode": "gcc-arm" } ``` ### 调试技巧 1. 生成编译命令数据库: ```bash cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ``` 2. 检查预处理结果: ```bash arm-none-eabi-gcc -E -dD -P stm32f1xx_it.c ``` > **重要提示**:STM32F103xB 的标准外设库默认不兼容 GNU 汇编语法[^1],建议: > 1. 使用 CMSIS 提供的标准启动文件 (如 `startup_stm32f103xb.s`) > 2. 避免直接修改汇编文件,通过 `-D` 宏定义配置芯片特性[^2] > 3. C++ 混合编程时确保链接 `-lstdc++` 并启用 RTTI[^3] ### 验证步骤 ```bash # 清理并重建 rm -rf build/ cmake -B build -G Ninja ninja -C build # 检查 ELF 文件 arm-none-eabi-objdump -d build/${PROJECT_NAME}.elf | less ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值