环境 Ubuntu16.04 g++ 5.4 thrift 0.11
thrift已安装正确,生成相应的cpp代码 进行服务端编译 makefile如下
1 CC=g++ -Wall -O2
2 CFLAGS=-I/usr/local/include/thrift -I./
3 LFLAGS=-L/usr/local/lib
4 LDEXEFLAGS=-lthrift
5 CPPDEFS=-DHAVE_NETINET_IN_H
6 SRC=test_service.cpp\
7 test_types.cpp\
8 test_constants.cpp
9
10 all: server
11
12 server: test_service_server.skeleton.cpp
13 ${CC} ${CPPDEFS} -o server ${CFLAGS} test_service_server.skeleton.cpp ${SRC} ${LFLAGS} ${LDEXEFLAGS}
14
15
16 clean:
17 rm -f ./*.o server
编译后出现
g++ -Wall -O2 -DHAVE_NETINET_IN_H -o server -I/usr/local/include/thrift -I./ test_service_server.skeleton.cpp test_service.cpp test_types.cpp test_constants.cpp -L/usr/local/lib -lthrift
/tmp/cckAX0Xn.o:在函数‘main’中:
test_service_server.skeleton.cpp:(.text.startup+0x299):对‘apache::thrift::server::TSimpleServer::TSimpleServer(boost::shared_ptrapache::thrift::TProcessor const&, boost::shared_ptr
:TServerTransport> const&, boost::shared_ptrapache::thrift::transport::TTransportFactory const&, boost::shared_ptrapache::thrift::protocol::TProtocolFactory const&)’未定义的引用
collect2: error: ld returned 1 exit status
makefile:13: recipe for target 'server' failed
make: *** [server] Error 1
这样的错误,但是查看资料,lthrift已经在最后,不知为何还会出错?