Undefined symbol RTC_DateStruct (referred from main.o).

本文分享了在使用extern关键字声明变量时遇到的错误“Undefined symbol”及其解决方案。通过删除在一个文件中不需要的extern声明,避免了变量重复定义的问题。

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

被自己蠢哭了  我是两个工程文件合在一起用的  一个工程中的.c文件变量定义之后是在另一个.c文件中共用的所以用了

extern RTC_TimeTypeDef RTC_TimeStruct;
extern RTC_DateTypeDef RTC_DateStruct;

这种extern的定义形式 可以在另一个文件去掉exrern再定义之后就可以两个文件一起用了

然而我就是在一个文件中使用的这两个变量 却还是带着extern  结果就一直是这个错误 Undefined symbol RTC_DateStruct (referred from main.o). 

把extern删掉就可以了

*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'E:\app\ARM\ARMCC\Bin' Rebuild target 'Target 1' assembling startup_stm32f10x_md.s... compiling stm32f10x_can.c... compiling stm32f10x_adc.c... compiling system_stm32f10x.c... compiling stm32f10x_dac.c... compiling misc.c... compiling stm32f10x_crc.c... compiling stm32f10x_dbgmcu.c... compiling stm32f10x_bkp.c... compiling stm32f10x_cec.c... compiling stm32f10x_dma.c... compiling stm32f10x_exti.c... compiling stm32f10x_flash.c... compiling core_cm3.c... compiling stm32f10x_fsmc.c... compiling stm32f10x_gpio.c... compiling stm32f10x_i2c.c... compiling stm32f10x_rtc.c... compiling stm32f10x_iwdg.c... compiling stm32f10x_pwr.c... compiling stm32f10x_rcc.c... compiling stm32f10x_sdio.c... compiling stm32f10x_spi.c... compiling stm32f10x_tim.c... compiling stm32f10x_usart.c... compiling oled.c... compiling rtc.c... compiling stm32f10x_it.c... compiling ultrasonic.c... compiling main.c... compiling stm32f10x_wwdg.c... compiling buzzer.c... Hardwore\buzzer.c(71): warning: #223-D: function "TIM_SetPrescaler" declared implicitly TIM_SetPrescaler(BUZZER_TIM, prescaler); Hardwore\buzzer.c: 1 warning, 0 errors compiling delay.c... compiling key.c... compiling mpu6050.c... linking... .\Objects\Project.axf: Error: L6218E: Undefined symbol TIM_SetPrescaler (referred from buzzer.o). .\Objects\Project.axf: Error: L6218E: Undefined symbol Alarm (referred from key.o). .\Objects\Project.axf: Error: L6218E: Undefined symbol alarm_active (referred from key.o). .\Objects\Project.axf: Error: L6218E: Undefined symbol alarm_mode (referred from key.o). Not enough information to list image symbols. Not enough information to list load addresses in the image map. Finished: 2 information, 0 warning and 4 error messages. ".\Objects\Project.axf" - 4 Error(s), 1 Warning(s). Target not created. Build Time Elapsed: 00:00:10
最新发布
07-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值