用Eclipse环境创建一个STM32F407工程。编译时出现错误。c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Huicheng\eclipse-workspace\Excise-F407\F407STDLibraryProject\Debug/../STM32F4xx_StdPeriph_Driver/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c:188: undefined reference to assert_failed' c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Huicheng\eclipse-workspace\Excise-F407\F407STDLibraryProject\Debug/../STM32F4xx_StdPeriph_Driver/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c:189: undefined reference to assert_failed'
c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Huicheng\eclipse-workspace\Excise-F407\F407STDLibraryProject\Debug/../STM32F4xx_StdPeriph_Driver/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c:190: undefined reference to assert_failed' c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Huicheng\eclipse-workspace\Excise-F407\F407STDLibraryProject\Debug/../STM32F4xx_StdPeriph_Driver/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c:208: undefined reference to assert_failed'
c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: ./STM32F4xx_StdPeriph_Driver/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.o:C:\Users\Huicheng\eclipse-workspace\Excise-F407\F407STDLibraryProject\Debug/../STM32F4xx_StdPeriph_Driver/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c:215: more undefined references to `assert_failed' follow
collect2.exe: error: ld returned 1 exit status。
检查stm32f4xx_gpio.c,stm32f4xx_gpio.h,.定义有。为什么报错 |
assert_failed
函数在头文件中声明的方式与在源文件中的定义完全一致。stm32f4xx_gpio.c
没有被正确编译。检查是否所有需要的源文件都被包含在了项目中,并且没有编译错误。assert_failed
在另一个库或源文件中定义,需要确保它在链接过程中出现在stm32f4xx_gpio.c
之前。assert_failed
的源文件中包含了定义该函数的头文件。assert_failed
函数依赖于外部库或特定的编译器特性,确保这些依赖已经正确解决。如果上述步骤都不能解决问题,你可以尝试以下操作: