firescript 发表于 2004-5-7 17:34:22

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


#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);
}   

# gcc -g -otcp tcp.c

/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

:oops:

firescript 发表于 2004-5-7 18:08:17

搞定了
UNP作者自己写的error.c
:oops::oops::oops:
页: [1]
查看完整版本: 请问这是怎么回事?(gcc) err_sys......