我正在做rpc的分配。当我运行命令"make -f Makefile.add"它向我抛出以下错误:
cc -g -o add_client add_clnt.o add_client.o add_xdr.o -lnsl
/usr/bin/ld: add_clnt.o: in function `add_1':
/home/mridu/rpc/add_clnt.c:18: undefined reference to `xdr_int'
/usr/bin/ld: /home/mridu/rpc/add_clnt.c:18: undefined reference to `xdr_int'
/usr/bin/ld: add_client.o: in function `add_prog_1':
/home/mridu/rpc/add_client.c:18: undefined reference to `clnt_create'
/usr/bin/ld: /home/mridu/rpc/add_client.c:20: undefined reference to `clnt_pcreateerror'
/usr/bin/ld: /home/mridu/rpc/add_client.c:27: undefined reference to `clnt_perror'
/usr/bin/ld: add_xdr.o: in function `xdr_numbers':
/home/mridu/rpc/add_xdr.c:13: undefined reference to `xdr_int'
/usr/bin/ld: /home/mridu/rpc/add_xdr.c:15: undefined reference to `xdr_int'
collect2: error: ld returned 1 exit status
make: *** [Makefile.add:41: add_client] Error 1
下面的代码是Makefile.add中的代码:
# This is a template Makefile generated by rpcgen
# Parameters
CLIENT = add_client
SERVER = add_server
SOURCES_CLNT.c =
SOURCES_CLNT.h =
SOURCES_SVC.c =
SOURCES_SVC.h =
SOURCES.x = add.x
TARGETS_SVC.c = add_svc.c add_server.c add_xdr.c
TARGETS_CLNT.c = add_clnt.c add_client.c add_xdr.c
TARGETS = add.h add_xdr.c add_clnt.c add_svc.c add_client.c add_server.c
OBJECTS_CLNT = $(SOURCES_CLNT.c:%.c=%.o) $(TARGETS_CLNT.c:%.c=%.o)
OBJECTS_SVC = $(SOURCES_SVC.c:%.c=%.o) $(TARGETS_SVC.c:%.c=%.o)
# Compiler flags
CFLAGS += -g
LDLIBS += -lnsl
LIBS+= -ltirrp
QMAKE_CXXFLAGS+= -ltirpc
RPCGENFLAGS =
# Targets
all : $(CLIENT) $(SERVER)
$(TARGETS) : $(SOURCES.x)
rpcgen $(RPCGENFLAGS) $(SOURCES.x)
$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) $(TARGETS_CLNT.c)
$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) $(TARGETS_SVC.c)
$(CLIENT) : $(OBJECTS_CLNT)
$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) $(LDLIBS)
$(SERVER) : $(OBJECTS_SVC)
$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)
clean:
$(RM) core $(TARGETS) $(OBJECTS_CLNT) $(OBJECTS_SVC) $(CLIENT) $(SERVER)
下面是add.x文件中的代码:
struct numbers{
int num1;
int num2;
};
program ADD_PROG{
version ADD_VER{
int ADD( numbers )=1;
}=1;
}=0x23456789;
我尝试添加编译器标志:
LIBS+= -ltirrp
QMAKE_CXXFLAGS+= -ltirpc
但它仍然不起作用。帮我解决这个问题!!
可能有点晚了,你可能已经解决了,但是,我认为你应该把LIBS
改为:
LIBS += -ltirpc