0
我是rpcgen編程的新手。 在編譯ubuntu上下面的示例的rpcgen例如我得到和error.The主要功能是計算在給定數量編譯在Ubuntu的rpcgen程序
的平方square.X
struct square_in {
long arg1;
};
struct square_out {
long res1;
};
program SQUARE_PROG {
version SQUARE_VERS {
square_out SQUAREPROC(square_in) = 1;
/* procedure number = 1 */
} = 1; /* version number = 1 */
} = 0x31230000; /* program number = 0x31230000 */
client.c
#include <rpc/rpc.h>
#include "square.h"
int
main(int argc, char **argv)
{
CLIENT *cl;
square_in in;
square_out *outp;
if (argc != 3)
//err_quit("usage: client <hostname> <integer-value>");
exit(0);
cl = clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, "tcp");
in.arg1 = atol(argv[2]);
if ((outp = squareproc_1(&in, cl)) == NULL)
//err_quit("%s", clnt_sperror(cl, argv[1]));
exit(0);
printf("result: %ld\n", outp->res1);
exit(0);
}
server.c
#include <rpc/rpc.h>
#include "square.h"
#include <stdio.h>
square_out *
squareproc_1_svc(square_in *inp, struct svc_req *rqstp)
{
static square_out out;
printf("thread %d started, arg = %ld\n",
pr_thread_id(NULL), inp->arg1);
sleep(5);
out.res1 = inp->arg1 * inp->arg1;
printf("thread %d done\n", pr_thread_id(NULL));
return(&out);
}
生成文件:
PROGS = client server
CFLAGS += -DDEBUG
all: ${PROGS}
square.h square_clnt.c square_svc.c square_xdr.c: square.x
rpcgen -C square.x
square_clnt.o: square_clnt.c square.h
square_svc.o: square_svc.c square.h
client: square.h client.o square_clnt.o square_xdr.o
${CC} ${CFLAGS} -o [email protected] client.o square_clnt.o square_xdr.o \
${LIBS} ${LIBS_RPC}
server: square.h server.o square_svc.o square_xdr.o
${CC} ${CFLAGS} -o [email protected] server.o square_svc.o square_xdr.o \
${LIBS} ${LIBS_RPC}
clean:
rm -f ${PROGS} ${CLEANFILES} *_clnt.c *_svc.c *_xdr.c square.h
在執行時,我得到以下錯誤:
cc -DDEBUG -c -o client.o client.c
cc -DDEBUG -o client client.o square_clnt.o square_xdr.o \
cc -DDEBUG -c -o server.o server.c
cc -DDEBUG -o server server.o square_svc.o square_xdr.o \
server.o: In function `squareproc_1_svc':
server.c:(.text+0x14): undefined reference to `pr_thread_id'
server.c:(.text+0x52): undefined reference to `pr_thread_id'
collect2: error: ld returned 1 exit status
make: *** [server] Error 1