title: What is this error undefined reference to 'xdr_numbers' in RPC
body: <p>power.x</p>
  
  <pre><code>struct numbers
  {
    int number;
    int power;
  };
  
  program POWER_PROG {
      version POWER_VERS {
              int power(numbers) = 1;
      } = 1;
  } = 0x31415926;
  </code></pre>
  
  <p>client.c</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;rpc/rpc.h&gt;
  #include "power.h"
  
  main(argc, argv)
  int argc;
  char **argv;
  {
  CLIENT *cl; /* rpc handle */
  char *server;
  
  int *result;
  
      numbers num;
  
  
  if (argc != 2) {
      fprintf(stderr, "usage:  %s hostname\n", argv[0]);
      exit(1);
  }
  server = argv[1];   /* get the name of the server */
  
  result = (int *)malloc(sizeof(int));
  
  /* create the client handle */
  if ((cl=clnt_create(server, FACT_PROG, FACT_VERS, "udp")) == NULL) 
  {
      /* failed! */
      clnt_pcreateerror(server);
      exit(1);
  }
  
  
  
  num.number=5;
  num.power=3;
  
  /* call the procedure bin_date */
  if ((result=fact_1(&amp;num, power, cl))==NULL) {
      /* failed ! */
      clnt_perror(cl, server);
      exit(1);
  }
  printf("Factorial returned from server is : %d\n", *result);
  
  clnt_destroy(cl);   /* get rid of the handle */
  exit(0);
  }
  </code></pre>
  
  <p>server.c</p>
  
  <pre><code> #include &lt;rpc/rpc.h&gt;
   #include "power.h"
  
   int temp;
   int *power_1_svc(numbers *num, struct svc_req *rqstp)
   {
      temp = 1;
      int i;
  
      for(i=1;i&lt;=num-&gt;power;i++)
          temp = temp * (num-&gt;number);
  
      return &amp;temp;
    }
  </code></pre>
  
  <p>In the above code, there is only one error occurring:</p>
  
  <pre><code>/tmp/cc604P8X.o: In function `power_prog_1':
  power_svc.c:(.text+0x4f): undefined reference to `xdr_numbers'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I compiled power.x file using the command: rpcgen power.x
  It generated all the files. But when I tried compiling server code, it gives the above error. </p>
  
  <pre><code> gcc -o server.out -DPRC_SVC_FG server.c power_svc.c
  </code></pre>
  
  <p>How to resolve this error? </p>