请教高手:
我用的MDK5.14,库函数版本3.5,探索者STM32F4开发板;
自己新建的工程,用原子哥的参考代码 SYSTEM 里面的usart.c,
//加入以下代码,支持printf函数,而不需要选择use MicroLIB
#if 1
#pragma import(__use_no_semihosting)
//标准库需要的支持函数
struct __FILE
{
int handle;
};
FILE __stdout;
//定义_sys_exit()以避免使用半主机模式
_sys_exit(int x)
{
x = x;
}
//重定义fputc函数
int fputc(int ch, FILE *f)
{
while((USART1->SR&0X40)==0);//循环发送,直到发送完毕
USART1->DR = (u8) ch;
return ch;
}
在不勾选 use microlib后,进行编译,会弹出如下错误:
..OBJPICTURE.axf: Error: L6200E: Symbol __stdout multiply defined (by stdio_streams.o and usart.o).
Not enough information to list image symbols.
Not enough information to list the image map.
Finished: 2 information, 0 warning and 1 error messages.
"..OBJPICTURE.axf" - 1 Error(s), 0 Warning(s).
如果我注释掉 FILE __stdout 这一行则会报出其他的错误:
linking...
..OBJPICTURE.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _sys_open was referenced
..OBJPICTURE.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _ttywrch was referenced
Finished: 0 information, 0 warning and 2 error messages.
"..OBJPICTURE.axf" - 2 Error(s), 0 Warning(s).
奇怪的是,如果直接用原子哥的模板工程则不会报错。
刚才我又试过直接用原子哥的模板,不会报错,添加自己的car车牌识别程序上去就会报这样的错误 把car移除就不会报错!
是不是我的car程序有地方出错了?可是又没检查出来!
希望有解决的大神指教下小弟
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
//¼óèëòÔÏÂ′úÂë,Ö§3Öprintfoˉêy,¶ø2»DèòaÑ¡Ôñuse MicroLIB
/*#if 1
#pragma import(__use_no_semihosting)
//±ê×¼¿aDèòaμÄÖ§3Öoˉêy
struct __FILE
{
int handle;
};
FILE __stdout;
//¶¨òå_sys_exit()òÔ±üÃaê1óðëÖ÷»úÄ£ê½
_sys_exit(int x)
{
x = x;
}
//Öض¨òåfputcoˉêy
int fputc(int ch, FILE *f)
{
while((USART1->SR&0X40)==0);//Ñ-»··¢Ëí,Ö±μ½·¢Ëííê±Ï
USART1->DR = (u8) ch;
return ch;
}
#endif */
/*ê1óÃmicroLibμÄ·½·¨*/
int fputc(int ch, FILE *f)
{
USART_SendData(USART1, (uint8_t) ch);
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) {}
return ch;
}
int GetKey (void) {
while (!(USART1->SR & USART_FLAG_RXNE));
return ((int)(USART1->DR & 0x1FF));
}
去掉之后出现
..OBJPICTURE.axf: Error: L6218E: Undefined symbol exit (referred from car.o).
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 1 error messages.
"..OBJPICTURE.axf" - 1 Error(s), 0 Warning(s).
百度上说 use MicroLib 不支持exit()函数 我的程序中是使用了exit()函数的。
if(img->bmp_type==1){bitcolor=2;printf("2»Äü¶áè¡íË3ö");exit(-1);}
if(img->bmp_type==4){bitcolor=16;printf("2»Äü¶áè¡íË3ö");exit(-1);}
好吧 摸索一个礼拜了 要不我上传我的程序上来给原子哥你看看吧
原子哥 这是源程序
一周热门 更多>