gpt4 book ai didi

c++ - Apache thrift 未定义对 apache::thrift::server::TNonblockingServer 的引用

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:44:54 34 4
gpt4 key购买 nike

我正在尝试编译一段创建 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 时执行了此处概述的步骤。 http://thrift.apache.org/docs/install/os_x/

这是我的生成文件

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

最佳答案

正如 Dmitry 所指出的,如果我们将 -lthriftnb 添加到编译命令中,就可以解决问题。这些缺失的引用在 libthriftnb.so 中找到,该文件包含对 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'

关于c++ - Apache thrift 未定义对 apache::thrift::server::TNonblockingServer 的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15288395/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com