在Linux下用GCC编译调用了sqrt()函数的程序,
提示 “undefined reference to 'sqrt'”的错误,
1 添加 #include<math.h>
2 链接math库,编译时需要加上 -lm 参数(链接math库)。
gcc -o a.out test.c -lm
在Linux下用GCC编译调用了sqrt()函数的程序,
提示 “undefined reference to 'sqrt'”的错误,
1 添加 #include<math.h>
2 链接math库,编译时需要加上 -lm 参数(链接math库)。
gcc -o a.out test.c -lm