如下面这个例子:
#include <math.h>
#include <stdio.h>
int main(void)
{
    double d = pow(2.0, 4.0);
    printf("The cubed is %f\n", d);
    return 0;
}我们想使用math.h库中的pow()函数,因此在编译时,需要连接对应的库。执行如下命令:
➜  test gcc -Wall calc.c -o calc -lm
➜  test ./calc 
The cubed is 16.000000其中-lm表示要链接libm.so或者libm.a库文件。
 我的书签
 我的书签
                                 添加书签
 添加书签 移除书签
 移除书签