20190311-Symbol xxx multiply defined (by xxx1.o and xxx2.o).为重复定义

本文探讨了在多个C源文件中引用同一头文件导致的Symbol重复定义错误。当全局变量在头文件中声明且初始化时,若多个源文件包含此头文件,编译链接时会出现重复定义错误。文章提供了解决方案,即确保只有一个源文件实际定义该变量,其余文件仅作外部引用。

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

Symbol xxx multiply defined (by xxx1.o and xxx2.o).为重复定义,需要使用external.
头文件h定义全局变量,其他.c(大于等于2个)引用时,可能会报出重复性定义。只要一个引用这个.H就没问题。
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin' Build target 'APP' compiling main.c... linking... APP\APP.axf: Error: L6200E: Symbol rx_buf multiply defined (by usart.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_buf multiply defined (by stm32f1xx_it.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_buf multiply defined (by logic.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_buf multiply defined (by periph.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_buf multiply defined (by schedule.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_buf multiply defined (by system.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_byte multiply defined (by usart.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_byte multiply defined (by stm32f1xx_it.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_byte multiply defined (by logic.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_byte multiply defined (by periph.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_byte multiply defined (by schedule.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_byte multiply defined (by system.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_flag multiply defined (by usart.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_flag multiply defined (by stm32f1xx_it.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_flag multiply defined (by logic.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_flag multiply defined (by periph.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_flag multiply defined (by schedule.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_flag multiply defined (by system.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_count multiply defined (by usart.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_count multiply defined (by stm32f1xx_it.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_count multiply defined (by logic.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_count multiply defined (by periph.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_count multiply defined (by schedule.o and main.o). APP\APP.axf: Error: L6200E: Symbol timeout_count multiply defined (by system.o and main.o). APP\APP.axf: Error: L6200E: Symbol uart_rx_complete multiply defined (by usart.o and main.o). APP\APP.axf: Error: L6200E: Symbol uart_rx_complete multiply defined (by stm32f1xx_it.o and main.o). APP\APP.axf: Error: L6200E: Symbol uart_rx_complete multiply defined (by logic.o and main.o). APP\APP.axf: Error: L6200E: Symbol uart_rx_complete multiply defined (by periph.o and main.o). APP\APP.axf: Error: L6200E: Symbol uart_rx_complete multiply defined (by schedule.o and main.o). APP\APP.axf: Error: L6200E: Symbol uart_rx_complete multiply defined (by system.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_index multiply defined (by usart.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_index multiply defined (by stm32f1xx_it.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_index multiply defined (by logic.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_index multiply defined (by periph.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_index multiply defined (by schedule.o and main.o). APP\APP.axf: Error: L6200E: Symbol rx_index multiply defined (by system.o and main.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 36 error messages. "APP\APP.axf" - 36 Error(s), 0 Warning(s). Target not created. Build Time Elapsed: 00:00:04
最新发布
07-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值