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

来源:互联网 发布:抠图软件在线使用 编辑:程序博客网 时间:2024/05/16 23:53

程序如下:

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


0 0
原创粉丝点击