您的位置:首页 > 运维架构 > Linux

GCC 编译linux运用程序开方错误的解决办法

2015-09-09 22:47 489 查看
程序如下:

test.c

#include<stdio.h>

#include<math.h>

#define SQ 121

int main(void)

{

int x;

x = sqrt(SQ);

return 0;

}

编译:gcc -g -o test test.c

GCC编译时显示错误,为sqrt没有定义

解决办法为:

用-lm把数学库链接进去

编译:gcc -g -o test test.c -ml
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: