QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1067|回复: 1

请问这是怎么回事?(gcc) err_sys......

[复制链接]
发表于 2004-5-7 17:34:22 | 显示全部楼层 |阅读模式
[code:1]
#include"unp.h"
int main(int argc ,char **argv)
{
int sockfd,n;
char recvline[MAXLINE+1];
struct sockaddr_in servaddr;
if(argc!=2)
   err_quit("usage:a.out<'IPaddress'>");
if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0)
   err_sys("socket error");
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family=AF_INET;
servaddr.sin_port=htons(13);
if(inet_pton(AF_INET,argv[1],&servaddr.sin_addr)<=0)
   err_quit("Inet_pton erro for %s",argv[1]);
if(connect(sockfd,(SA *)&servaddr,sizeof(servaddr))<0)
   err_sys("connet erro");
while((n=read(sockfd,recvline,MAXLINE))>0)
{
   recvline[n]=0;
   if(fputs(recvline,stdout)==EOF)
       err_sys("fputs erro");
}
if(n<0)
   err_sys("read erro");
exit(0);
}     
[/code:1]
[root@firescript root]# gcc -g -o  tcp tcp.c
[code:1]
/tmp/ccKiMmft.o(.text+0x22): In function `main':
/root/tcp.c:8: undefined reference to `err_quit'
/tmp/ccKiMmft.o(.text+0x4c):/root/tcp.c:10: undefined reference to `err_sys'
/tmp/ccKiMmft.o(.text+0xb8):/root/tcp.c:15: undefined reference to `err_quit'
/tmp/ccKiMmft.o(.text+0xe3):/root/tcp.c:17: undefined reference to `err_sys'
/tmp/ccKiMmft.o(.text+0x142):/root/tcp.c:22: undefined reference to `err_sys'
/tmp/ccKiMmft.o(.text+0x15a):/root/tcp.c:25: undefined reference to `err_sys'
collect2: ld returned 1 exit status
[/code:1]
 楼主| 发表于 2004-5-7 18:08:17 | 显示全部楼层
搞定了
UNP作者自己写的  error.c
    
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-16 11:31 , Processed in 0.057964 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表