#include <math.h>
#include <stdio.h>
int main()
{
printf("%f", roundf(3.14));
}
我编译上面的代码(未使用-lm),添加使用LDD的a.out,结果是为什么它不需要链接libm?
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中。 – 2013-04-25 00:26:40
IIRC代表交叉工具吗? – snyh 2013-04-25 00:32:45
IIRC =“如果我记得正确” – Tim 2013-04-25 00:41:57