|
|
比如我有一个程序如下:
#include <math.h>
int main()
{
double db = 0.0;
db = sqrt(10.0);
return 0;
}
保存为test.c
编译运行gcc -c test.c,产生test.o,正确,但下面链接出错:
gcc -o test test.o
出现错误:
test.o(.text+0x29):In function 'main':
:undefined reference to 'sqrt'
collect2:ld returned 1 exit status
难道是链接标准库<math.h>出错误了?怎么会这样,怎么解决?谢谢! |
|