对 log10 函数的未定义引用 [英] Undefined reference to log10 function
问题描述
我正在使用 Eclipse Kepler 构建,并且包含了 math.h
.但是,我收到一个错误
I am building using Eclipse Kepler, and have included math.h
. However, I am getting an error
'未定义对 log10 的引用'.
'undefined reference to log10'.
还没有解析 uint8_t
和 unit32_t
类型.我已经包括了 stdint.h
和 inttypes.h
,只是为了确定,但没有成功.有人可以帮忙吗?
Also types uint8_t
and unit32_t
are not being resolved. I have included both stdint.h
and inttypes.h
, just to be sure, but wasn't successful. Can someone kindly help?
推荐答案
'未定义对 log10 的引用'.
因为头文件只提供了函数的前向声明.实际的函数定义存在于 ("math") 库中.您需要使用 -lm
链接数学库.
Because, the header file only provides the forward declaration of the function. The actual function definition is present in the ("math") library. You need to link with the math library using -lm
.
参考:手册页 log10代码>
此外,AFAIK、uint
存在于
中.请检查您的代码中是否存在头文件本身和/或任何拼写错误(如您的示例中的 unit32_t
).
Also, AFAIK, uint<N>_t
are present in <stdint.h>
. Please check for the existence for the header file itself and/or any typos (like unit32_t
in your example) in your code.
这篇关于对 log10 函数的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!