c - What is this error undefined reference to 'xdr_numbers' in RPC -
power.x
struct numbers { int number; int power; }; program power_prog { version power_vers { int power(numbers) = 1; } = 1; } = 0x31415926;
client.c
#include <stdlib.h> #include <stdio.h> #include <rpc/rpc.h> #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]; /* name of server */ result = (int *)malloc(sizeof(int)); /* create 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 procedure bin_date */ if ((result=fact_1(&num, power, cl))==null) { /* failed ! */ clnt_perror(cl, server); exit(1); } printf("factorial returned server : %d\n", *result); clnt_destroy(cl); /* rid of handle */ exit(0); }
server.c
#include <rpc/rpc.h> #include "power.h" int temp; int *power_1_svc(numbers *num, struct svc_req *rqstp) { temp = 1; int i; for(i=1;i<=num->power;i++) temp = temp * (num->number); return &temp; }
in above code, there 1 error occurring:
/tmp/cc604p8x.o: in function `power_prog_1': power_svc.c:(.text+0x4f): undefined reference `xdr_numbers' collect2: error: ld returned 1 exit status
i compiled power.x file using command: rpcgen power.x generated files. when tried compiling server code, gives above error.
gcc -o server.out -dprc_svc_fg server.c power_svc.c
how resolve error?
Comments
Post a Comment