这个程序编译时会出错!

大虾帮助:
程序如下:a.c
#include

 1<math.h>   
 2#include <stdio.h>   
 3main()   
 4{   
 5double f;   
 6f=sqrt(4.0);   
 7printf("%f",f);   
 8}   
 9  
10当编译时 (用cc a.c )会出现如下错误   
11undefined first referenced   
12symbol in file   
13sqrt a.o   
14i386ld fatal:Symbol referencing errors.No output writen to a.out   
15  
16我的系统是sco unix 5。05,请大虾帮助。谢谢   
17\---------------------------------------------------------------   
18  
19cc a.c -lmath   
20加上数学库。。   
21\---------------------------------------------------------------   
22  
23你编译时应加-lm选项,即:cc -O -o a a.c -lm 当然,可以写在Makefile中   
24\---------------------------------------------------------------   
25  
26哦,原来是要-lmath啊,我原来把它包含math.h都不行,试一试先!   
27\---------------------------------------------------------------   
28  
29cc -o test test.c -lm   
30就行了,出来是 2。000000000   
31没有错,支持root3楼上</stdio.h></math.h>
Published At
Categories with 服务器类
Tagged with
comments powered by Disqus