error:#5:cannotopensourceinputfile"stm32f10x_lib.h":Nosuchfileordirectory

在STM32项目中遇到移植固件库时出现的错误提示cannot open source input file,通过替换库文件引用并重建工程,成功解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题现象:

test.c(1):error:#5:cannotopensourceinputfile"stm32f10x_lib.h":Nosuchfileordirectory
compilingdelay.c...
..\SYSTEM\delay\delay.c(1):error:#5:cannotopensourceinputfile"stm32f10x_lib.h":Nosuchfileordirectorycompilingsys.c...
..\SYSTEM\sys\sys.c(1):error:#5:cannotopensourceinputfile"stm32f10x_lib.h":Nosuchfileordirectorycompilingusart.c...
..\SYSTEM\sys\sys.h(3):error:#5:cannotopensourceinputfile"stm32f10x_lib.h":Nosuchfileordirectorycompilingled.c...
..\HARDWARE\LED\led.c(1):error:#5:cannotopensourceinputfile"stm32f10x_lib.h":NosuchfileordirectoryTargetnotcreated


问题分析:

ST的固件库旧版本才有"stm32f10x_lib.h" ,如果使用旧库的程序移植到新库工程中引起


解决办法:


#include "stm32f10x_lib.h" ->  "#include "stm32f10x.h" 再重新 rebulid 就可以解决了 ^_^。


Rebuild target 'Target 1' compiling core_cm3.c... assembling startup_stm32f10x_md.s... compiling system_stm32f10x.c... compiling misc.c... compiling stm32f10x_adc.c... compiling stm32f10x_bkp.c... compiling stm32f10x_can.c... compiling stm32f10x_cec.c... compiling stm32f10x_crc.c... compiling stm32f10x_dac.c... compiling stm32f10x_dbgmcu.c... compiling stm32f10x_dma.c... compiling stm32f10x_exti.c... compiling stm32f10x_flash.c... compiling stm32f10x_fsmc.c... compiling stm32f10x_gpio.c... compiling stm32f10x_i2c.c... compiling stm32f10x_it.c... compiling stm32f10x_iwdg.c... compiling stm32f10x_pwr.c... compiling stm32f10x_rcc.c... compiling stm32f10x_rtc.c... compiling stm32f10x_sdio.c... compiling stm32f10x_spi.c... compiling stm32f10x_tim.c... compiling stm32f10x_usart.c... compiling stm32f10x_wwdg.c... compiling main.c... compiling dht11.c... Driver\src\dht11.c(31): error: #20: identifier "GPIO_InitStructure" is undefined GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; Driver\src\dht11.c: 0 warnings, 1 error compiling oled.c... .\Driver\inc\i2c.h(16): warning: #1-D: last line of file ends without a newline #endif Driver\src\oled.c(3): error: #5: cannot open source input file "font.h": No such file or directory #include "font.h" // 瀛楀簱鏁版嵁 Driver\src\oled.c: 1 warning, 1 error compiling vibration.c... compiling voice.c... compiling fan.c... compiling delay.c... compiling i2c.c... .\Driver\inc\i2c.h(16): warning: #1-D: last line of file ends without a newline #endif Driver\src\i2c.c(6): error: #147-D: declaration is incompatible with "void I2C_Init(I2C_TypeDef *, I2C_InitTypeDef *)" (declared at line 535 of ".\Lib\inc\stm32f10x_i2c.h") void I2C_Init(void) { Driver\src\i2c.c(11): error: #20: identifier "I2C_SCL_PIN" is undefined GPIO_InitStructure.GPIO_Pin = I2C_SCL_PIN | I2C_SDA_PIN; Driver\src\i2c.c(11): error: #20: identifier "I2C_SDA_PIN" is undefined GPIO_InitStructure.GPIO_Pin = I2C_SCL_PIN | I2C_SDA_PIN; Driver\src\i2c.c(14): error: #20: identifier "I2C_PORT" is undefined GPIO_Init(I2C_PORT, &GPIO_InitStructure); Driver\src\i2c.c: 1 warning, 4 errors ".\Objects\project1.axf" - 6 Error(s), 2 Warning(s). Target not created. Build Time Elapsed: 00:00:13
06-24
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值