以下程序无法在gcc中编译。但在带有
错误信息:
.c
扩展名的g++和MSC++中可以正常编译。#include <math.h>
#include <stdio.h>
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
这是一个bug吗?
有人能够帮我进行测试吗?