【发布时间】:2013-04-25 00:25:19
【问题描述】:
#include <math.h>
#include <stdio.h>
int main()
{
printf("%f", roundf(3.14));
}
我编译上面的代码(没用-lm),加上use ldd a.out,结果是
linux-vdso.so.1 => (0x00007fffab9ff000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd6da0f8000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd6da4eb000)
为什么 a.out 没有与 libm 链接但可以使用 roundf(或类似 sqrt 的东西)? 我使用 nm 来测试 libc.so.6 和 ld-linux-x86064.so.2 但所有这些都没有 roundf 的符号。
我想知道 roundf 是在哪里定义的,还是被编译器内联了? (使用 gcc 4.7.3 和 gcc 4.6.3 进行测试)
答案是http://fedoraproject.org/w/index.php?title=UnderstandingDSOLinkChange
【问题讨论】:
-
这些存在于 libc IIRC 中。
-
IIRC 代表跨工具吗??
-
IIRC = "如果我没记错的话"
-
谢谢你的解释@Tim