×
单片机 > 单片机程序设计 > 详情

LPC2132学习中遇到的错误1

发布时间:2020-09-01 发布时间:
|
自己写了一个头文件LCD.H,在其中定义了如下的全局变量:
const int8 NoCheckBusy = 0;
const int8 CheckBusy = 1;
 
const int32 LCD_RS = 1<<4;
const int32 LCD_RW = 1<<5;
const int32 LCD_EN = 1<<6;
const int32 LCD_DATA = 0xff<<7;
 
在c文件lcd.c和main.c中都要用到,但是在编译的时候出现如下的问题:
Error: L6200E: Symbol NoCheckBusy multiply defined (by main.o and lcd.o).
Error: L6200E: Symbol LCD_RS multiply defined (by main.o and lcd.o).
 
上网站http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0435a/index.html上去查找,有如下结果:
 
L6200E: Symbol multiply defined (by and ).
There are two common examples where this occurs:
 1) Symbol __semihosting_swi_guard multiply defined (by use_semi.o and use_no_semi.o).
This error is reported when functions that use semihosting SWIs are linked in from the C library, in the presence of the __use_no_semihosting_swi guard.  See the ADS 1.2 Compilers and Libraries Guide, section 4.2.2, "Building an application for a nonsemihosted environment" and ADS 1.2 Developer Guide, Section 6.10.1, "Linker error __semihosting_swi_guard".
To resolve this, you must provide your own implementations of these C library functions.
The ADS 1.2 Examplesembedded directory contains examples of how to re-implement some of the more common SWI-using functions - see the file retarget.c.
To identify which SWI-using functions are being linked-in from the C libraries:
1. Link with 'armlink -verbose -errors err.txt'
2. Search err.txt for occurrences of '__I_use_semihosting_swi'
For example:
:
Loading member sys_exit.o from c_a__un.l.
              reference :  __I_use_semihosting_swi
              definition:  _sys_exit
:
This shows that the SWI-using function _sys_exit is being linked-in from the C library.  To prevent this, you will need to provide your own implementation of this function.
 2) Symbol __stdout multiply defined (by retarget.o and stdio.o).
This means that there are two conflicting definitions of __stdout present – one inretarget.o, the other in stdio.o.  The one in retarget.o is your own definition.  The one in stdio.o is the default implementation, which was probably linked-in inadvertently.
stdio.o contains a number symbol definitions and implementations of file functions like fopen, fclose, fflush, etc.  stdio.o is being linked-in because it satisfies some unresolved references.
To identify why stdio.o is being linked-in, you must link with the linker's "verbose" switch, e.g.:
     armlink [... your normal options...] -verbose -errors err.txt
Then study err.txt, so see exactly what the linker is linking-in, from where, and why.
To move forward, the user may have to either:
- Eliminate the calls like fopen, fclose, fflush, etc, or
- Re-implement the _sys_xxxx family of functions.
 See the ADS 1.2 Compilers and Libraries Guide, section 4.10, "Tailoring the input/output functions".
具体是什么意思看的也不是很懂,后来看了别人的解决方法是:在头文件中仅声明变量,而把变量的定义都放到c文件中去,问题就解决了。
即把
 
const int8 NoCheckBusy = 0;
const int8 CheckBusy = 1;
 
const int32 LCD_RS = 1<<4;
const int32 LCD_RW = 1<<5;
const int32 LCD_EN = 1<<6;
const int32 LCD_DATA = 0xff<<7;
 
都放到lcd.c中就可避免该问题,时间不多,具体原因还有待研究。



『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
STM32单片机的复用端口初始化的步骤及方法