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

Re:



hi ashish,
    no. there is no need to add anymore header file. you just will have
to type in the function err_sys() in your code. this, you can either
write your own code, or, copy the code in stevens book, pg. 724, Seventh
Indian Reprint (Appendix A, Standard Error Routines).

arvind.

Ashish wrote:

> 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
>
>
>
> ---------------------------------------------
> Find out more about this and other Linux India
> mailing lists at http://lists.linux-india.org/