王富贵丶大人 2023-08-04 16:26
浏览 108
已结题

S32DS.ARM.2.2平台math函数使用编译报错

基于S32K144 RTM v3.0.0版本创建的HELLOW WORLD demo工程,使用数学函数时编译报错

img

报错内容:未定义函数 asinf,sqrt,atan2f等(已添加头文件math.h)
#include "Cpu.h"
#include <math.h>

int constant1 = 9;
int constant2 = 16;
int constant3 = 0;
int constant4 = 0;

int main(void)
{
  while(1)
  {
      constant1 = sqrt(constant1);
      constant2 = asinf(constant2);
      constant3 = atan2f(constant1,constant2);
      constant4 = sqrt(4);
  }
}
Description Resource Path Location Type

Ld error: undefined reference to asinf' hello_world_s32k144 C/C++ ProblemDescription Resource Path Location Type Ld error: undefined reference to atan2f' hello_world_s32k144 C/C++ ProblemDescription Resource Path Location Type
Ld error: undefined reference to `sqrt' hello_world_s32k144 C/C++ Problem

在stm32单片机上都没问题,这个报错要怎么解决呢。再次强调有添加math.h的头文件

img

img

  • 写回答

1条回答 默认 最新

  • 王富贵丶大人 2023-08-04 16:50
    关注

    自己找到原因了:编译器问题 添加Libraies-lm

    img

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 8月4日
  • 创建了问题 8月4日