返回列表 发新帖

AVR Studio 5调用数学函数出错。

[复制链接]

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-4-6 11:50:16 | 显示全部楼层 | 阅读模式
包含math.h后,在程序中调用了sinf,cosf,tanf等,

#include "./math.h"
double GetSinAvg(uint *num,uint len)
{
double sum=0.0;
for(uint i=0;i<len;i++)
{
  sum+=sin(*(num+i)*M_PI/180.0);
}
return sum/len;
}

编译时总提示:

Error 1 R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in d:/program files/atmel/avr studio 5.0/avr toolchain/bin/../lib/gcc/avr/4.5.1/avrxmega7\libgcc.a(_mul_sf.o) /home/tools/hudson/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/square.S 43 1 DataCollector
Error 2 R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in d:/program files/atmel/avr studio 5.0/avr toolchain/bin/../lib/gcc/avr/4.5.1/avrxmega7\libgcc.a(_mul_sf.o) /home/tools/hudson/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/fp_powsodd.S 59 1 DataCollector
Error 3 R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in d:/program files/atmel/avr studio 5.0/avr toolchain/bin/../lib/gcc/avr/4.5.1/avrxmega7\libgcc.a(_mul_sf.o) /home/tools/hudson/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/fp_powsodd.S 69 1 DataCollector

不知什么问题,请高手帮忙解决,谢谢。
回复

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-4-7 13:56:59 | 显示全部楼层
用AVR Studio 5.1编译就没问题了,奇怪
回复 支持 反对

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-4-17 07:40:37 | 显示全部楼层
问题解决,原来GCC编译器默认情况下,在链接时不会把数学库libm.a链接进去,解决方法有两种:
一、修改MakeFile,加入-lm选项。
二、在图形界面中修改,如下图。 添加数学库.jpg
回复 支持 反对

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-4-17 07:42:36 | 显示全部楼层
至于为什么AVR Studio5.1和6.0编译后的Hex不能运行(所有优化选项都试过),还有待于高手解决。
回复 支持 反对

使用道具 举报

发表回复

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

本版积分规则

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