简体   繁体   English

Apache thrift undefined对apache :: thrift :: server :: TNonblockingServer的引用

[英]Apache thrift undefined reference to apache::thrift::server::TNonblockingServer

I'm trying to compile a piece of code that creates a TNonblockingServer and I get the following compile error. 我正在尝试编译一段创建TNonblockingServer的代码,我得到以下编译错误。 Any idea what's wrong? 知道什么是错的吗?

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()'

I performed the steps outlined here while installing thrift. 我在安装thrift时执行了这里列出的步骤。 http://thrift.apache.org/docs/install/os_x/ http://thrift.apache.org/docs/install/os_x/

Here's my makefile 这是我的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

As pointed out by Dmitry, if we add -lthriftnb to compiling command, it solves the problem. 正如Dmitry所指出的,如果我们将-lthriftnb添加到编译命令中,它就可以解决问题。 These missing references are found in libthriftnb.so This file has references to libevent. 这些缺少的引用可以在libthriftnb.so中找到。这个文件引用了libevent。 So I had to include -levent to compiling command. 所以我不得不包括-levent来编译命令。 Without -levent linker generates multiple error messages. 没有-levent链接器会生成多个错误消息。 Some of the messages are as follows - 一些消息如下 -

/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'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM