Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Apache thrift未定义对Apache::thrift::server::TNonblockingServer的引用_C++_Rpc_Thrift - Fatal编程技术网

C++ Apache thrift未定义对Apache::thrift::server::TNonblockingServer的引用

C++ Apache thrift未定义对Apache::thrift::server::TNonblockingServer的引用,c++,rpc,thrift,C++,Rpc,Thrift,我试图编译一段创建TNonblockingServer的代码,我得到以下编译错误。知道怎么了吗 something_server.cpp:(.text+0x1ad): undefined reference to `apache::thrift::server::TNonblockingServer::serve()' something_server.cpp:(.text+0x1c1): undefined reference to `apache::thrift::server::TNonb

我试图编译一段创建TNonblockingServer的代码,我得到以下编译错误。知道怎么了吗

something_server.cpp:(.text+0x1ad): undefined reference to `apache::thrift::server::TNonblockingServer::serve()'
something_server.cpp:(.text+0x1c1): undefined reference to `apache::thrift::server::TNonblockingServer::~TNonblockingServer()'
something_server.cpp:(.text+0x280): undefined reference to `apache::thrift::server::TNonblockingServer::~TNonblockingServer()'
我在安装thrift时执行了此处概述的步骤。

这是我的makefile

GEN_SRC := Something.cpp something_constants.cpp something_types.cpp
GEN_OBJ := $(patsubst %.cpp,%.o, $(GEN_SRC))

THRIFT_DIR := /usr/local/include/thrift
BOOST_DIR := /usr/local/include

INC := -I$(THRIFT_DIR) -I$(BOOST_DIR)

.PHONY: all clean

all: something_server something_client

%.o: %.cpp 
    $(CXX) -Wall -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H $(INC) -c $< -o $@ 

something_server: something_server.o $(GEN_OBJ)
    $(CXX) $^ -o $@ -L/usr/local/lib -lthrift 

something_client: something_client.o $(GEN_OBJ)
    $(CXX) $^ -o $@ -L/usr/local/lib -lthrift 

clean: 
    $(RM) *.o something_server something_client
GEN\u SRC:=Something.cpp Something\u constants.cpp Something\u types.cpp
GEN_OBJ:=$(patsubst%.cpp,%.o,$(GEN_SRC))
THRIFT_DIR:=/usr/local/include/THRIFT
BOOST_DIR:=/usr/local/include
INC:=-I$(节俭目录)-I$(提高目录)
.骗子:都是干净的
all:something\u server something\u client
%.o:%.cpp
$(CXX)-Wall-DHAVE\u INTTYPES\u H-DHAVE\u NETINET\u IN\u H$(INC)-c$<-o$@
something\u server:something\u server.o$(GEN\u OBJ)
$(CXX)$^-o$@-L/usr/local/lib-lthrift
something\u client:something\u client.o$(GEN\u OBJ)
$(CXX)$^-o$@-L/usr/local/lib-lthrift
清洁:
$(RM)*.o某物\u服务器某物\u客户端

正如Dmitry所指出的,如果我们在编译命令中添加
-lthritnb
,它就解决了问题。这些缺少的引用在libthriftnb中找到,因此此文件具有对libevent的引用。所以我必须在编译命令中包含
-levent
。如果没有
-levent
,链接器将生成多条错误消息。其中一些信息如下-

/usr/local/lib/libthriftnb.so: undefined reference to `event_set'
/usr/local/lib/libthriftnb.so: undefined reference to `evbuffer_new'
/usr/local/lib/libthriftnb.so: undefined reference to `evhttp_free'
.
.
.
.
/usr/local/lib/libthriftnb.so: undefined reference to `event_del'

由于没有链接库,这看起来像是一个普通的链接问题。你是如何编译和链接的?我已经编辑了这个问题并添加了我的makefile。尝试将-lthritnb库添加到你的Makefilethx Dmitry,你的评论帮助很大:-)