野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 16199|回复: 8

用MDK5编译程序的时候出现编译时 _stdout 在stdio_streams.o and usart.o中重复定义

[复制链接]
发表于 2016-8-22 23:10:23 | 显示全部楼层 |阅读模式
用MDK5编译程序的时候出现编译时 _stdout 在stdio_streams.o and usart.o中重复定义

//加入以下代码,支持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后,进行编译,会弹出如下错误:
..\OBJ\PICTURE.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.
"..\OBJ\PICTURE.axf" - 1 Error(s), 0 Warning(s).

如果我注释掉 FILE __stdout 这一行则会报出其他的错误:
linking...
..\OBJ\PICTURE.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _sys_open was referenced
..\OBJ\PICTURE.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _ttywrch was referenced
Finished: 0 information, 0 warning and 2 error messages.
"..\OBJ\PICTURE.axf" - 2 Error(s), 0 Warning(s).

请各位前辈给我解惑,QQ 1278219774    邮箱1278219774@qq.com


回复

使用道具 举报

发表于 2016-8-23 08:42:47 | 显示全部楼层
使用这种功能的时候直接勾选use microlib就可以了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-8-23 12:26:12 | 显示全部楼层
随风 发表于 2016-8-23 08:42
使用这种功能的时候直接勾选use microlib就可以了

勾选之后也是编译错误
..\OBJ\PICTURE.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.
回复 支持 反对

使用道具 举报

发表于 2016-8-23 19:56:34 来自手机 | 显示全部楼层
把你工程传上来
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-8-24 01:05:32 | 显示全部楼层
fire 发表于 2016-8-23 19:56
把你工程传上来

源程序  火哥你帮看看

源程序.rar

4.88 MB, 下载次数: 32

这是源程序

回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-8-24 01:08:13 | 显示全部楼层
fire 发表于 2016-8-23 19:56
把你工程传上来

这是学长发给我的最原始程序   里面的sram.c没有添加进工程中!
回复 支持 反对

使用道具 举报

发表于 2016-8-24 08:29:19 | 显示全部楼层
xue 发表于 2016-8-24 01:08
这是学长发给我的最原始程序   里面的sram.c没有添加进工程中!

现在解决啦?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-8-24 13:24:27 | 显示全部楼层

没有  应该是移植car.c程序哪里出问题了,我看了一遍没发现问题在哪!麻烦火哥给我看看
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-8-30 11:02:20 | 显示全部楼层
怎么沉了   别沉啊 !!!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-6-19 01:42 , Processed in 0.032599 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表