[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

[no subject]



Hi,

I have just started to learn network programming.
I tried to run a c program from Stevens book on network 
programming. 

The program is

#include<stdio.h>
#include<varargs.h>
#include<sys/types.h>
#include<sys/stat.h>

main()

{
 int pipefd[2], n ;
 char buff[100] ;

 if( pipe(pipefd) < 0)
   err_sys("pipe erroe");
 
 printf("read fd = %d, write fd = %d\n", pipefd[0], pipefd[1]);
 
 if(write(pipefd[1], "hello world",12) != 12)
   err_sys("write error");
 
 if( (n = read(pipefd[0], buff ,sizeof(buff))) <= 0 )
   err_sys("read error");

 write(1, buff, n);

 exit(0);

}


Its giving error as follows:

/tmp/cc6q5fia.o: In function `main':
/tmp/cc6q5fia.o(.text+0x1e): undefined reference to `err_sys'
/tmp/cc6q5fia.o(.text+0x5a): undefined reference to `err_sys'
/tmp/cc6q5fia.o(.text+0x84): undefined reference to `err_sys'
collect2: ld returned 1 exit status

I am compiling on linux. Is there any header file I am not including?
Please let me know what's the problem

bye
Ashish