【问题标题】:Undefined reference to log10 function未定义对 log10 函数的引用
【发布时间】:2015-10-02 21:19:39
【问题描述】:

我正在使用 Eclipse Kepler 构建,并包含 math.h。但是,我收到一个错误

'未定义对 log10 的引用'。

还没有解析uint8_tunit32_t 类型。我已经包括了stdint.hinttypes.h,只是为了确定,但没有成功。有人可以帮忙吗?

【问题讨论】:

  • 是的,这是一个错字@SouravGhosh。
  • @SouravGhosh:我知道如何使用 shell 编程在 ubuntu 中进行链接,但我对此很陌生。你能指导更多吗?
  • 使用gcc something.c -lm

标签: c undefined-reference


【解决方案1】:

'未定义对 log10 的引用'。

因为头文件只提供了函数的前向声明。实际的函数定义存在于(“数学”)库中。您需要使用 -lm 链接到数学库。

参考:man page for log10

另外,AFAIK,uint<N>_t 出现在<stdint.h> 中。请检查代码中是否存在头文件本身和/或任何拼写错误(例如您的示例中的unit32_t)。

【讨论】:

  • 'undefined',而不是'unresolved'听起来像是编译器错误,而不是链接器?
猜你喜欢
  • 1970-01-01
  • 2022-01-05
  • 2019-09-05
  • 2011-09-19
  • 2017-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-09
相关资源
最近更新 更多