Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache thrift undefined reference to apache::thrift::server::TNonblockingServer

Tags:

c++

rpc

thrift

I'm trying to compile a piece of code that creates a TNonblockingServer and I get the following compile error. 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. http://thrift.apache.org/docs/install/os_x/

Here's my 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
like image 492
Manish Burman Avatar asked Mar 08 '13 06:03

Manish Burman


1 Answers

As pointed out by Dmitry, if we add -lthriftnb to compiling command, it solves the problem. These missing references are found in libthriftnb.so This file has references to libevent. So I had to include -levent to compiling command. Without -levent linker generates multiple error messages. 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'
like image 95
Aryaveer Avatar answered Oct 06 '22 01:10

Aryaveer