以下程序无法在gcc中编译.但它与g ++和MSC++的.c
扩展编译正常.
#include#include int main() { double t = 10; double t2 = 200; printf("%lf\n", sqrt(t*t2)); return 0; }
我的系统是CentOS,版本信息.
> gcc --version gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
错误信息:
> gcc test.c /tmp/ccyY3Hiw.o: In function `main': test.c:(.text+0x55): undefined reference to `sqrt' collect2: ld returned 1 exit status
这是一个错误吗?
任何人都可以为我做测试吗?
你有没有连接数学库?
gcc -lm test.c -o test