我在Raspberry PI中的pow()遇到了问题。我使用它,简单地像这样转动gpio引脚:
*((unsigned int *)(GPIO_PIN_ON)) = ( 1 * pow(2,16) ); // 1 << 16GPIO_PIN_ON是我在顶部定义的常量。这可以很好地工作。我甚至不需要包含"Math.h“,但当我在其他文件中创建"GPIOsetFunction()”并使用pow()时,即使与"math.h“库一起使用,它也会给出这个错误:
gpio.c:(.text+0x38): undefined reference to `__aeabi_i2d'
gpio.c:(.text+0x48): undefined reference to `__aeabi_i2d'
>> gpio.c:(.text+0x64): undefined reference to `pow'
gpio.c:(.text+0x80): undefined reference to `__aeabi_dmul'
gpio.c:(.text+0x94): undefined reference to `__aeabi_d2iz'在这里,它表示没有定义pow()。有人能帮帮我吗?
附言:我正在将BakingPI教程从汇编转换成C语言,我不想使用移位运算符。
下面是我在没有"math.h“和没有"-lm”的情况下成功运行的代码,如果"-lm“是解决方案,我如何能够运行它?(这是一个完整的代码OK-02的烘焙-PI教程)
P.S2:我正在使用YAGARTO编译器。
#include <sys/types.h>
void main(void);
#define GPIO_BASE 538968064 //0x20200000
#define GPIO_PIN_FUNC (GPIO_BASE+4)
#define GPIO_PIN_ON (GPIO_BASE+28)
#define GPIO_PIN_OFF (GPIO_BASE+40)
void main(void) {
register int counter = 0;
*((unsigned int *)(GPIO_PIN_FUNC)) = ( 1 * pow(2,18) ); //1 << 18
while (1 == 1) { // forever
*((unsigned int *)(GPIO_PIN_OFF)) = ( 1 * pow(2,16) ); //1 << 16
counter = 4128768; //0x3f0000;
while (counter--);
*((unsigned int *)(GPIO_PIN_ON)) = ( 1 * pow(2,16) ); // 1 << 16
counter = 4128768; //0x3f0000;
while (counter--);
}
// should never get here
} 发布于 2014-06-17 16:54:53
你必须链接到数学库。将-lm附加到编译(链接)命令行。
https://stackoverflow.com/questions/24259507
复制相似问题