无法编译成a.out文件

编译时,出现以下错误,我不懂为什么出错,以及怎么处理.
unix编程学习很辛苦呢,相关资料又少,各位帮忙了,小弟多谢!

258$ cc uname.c
undefined first referenced
symbol in file
gethostname uname.o
i386ld fatal: Symbol referencing errors. No output written to a.out

cat uname.c

#include

 1<stdlib.h>   
 2#include <unistd.h>   
 3#include <errno.h>   
 4#ifndef MAXHOSTNAMELEN   
 5#define MAXHOSTNAMELEN 256   
 6#endif   
 7  
 8main()   
 9{   
10char hostname[MAXHOSTNAMELEN];   
11long hostid;   
12size_t size;   
13  
14size= MAXHOSTNAMELEN;   
15  
16if (gethostname(hostname,size) != 0)   
17{   
18printf("could not gethost name \n");   
19exit(1);   
20}   
21hostid = gethostid();   
22printf("hostname=%s\nhostid=%d\n",hostname,hostid);   
23}   
24  
25  
26\---------------------------------------------------------------   
27  
28SCO: cc uname.c -lsocket   
29连上socket库。</errno.h></unistd.h></stdlib.h>
Published At
Categories with 服务器类
Tagged with
comments powered by Disqus