把thrift 自带的cpp的例子改了一下,用来测试。因为要作为客户端部署,所以要将thrit静态编译进去。改了一下thrift例子里面的cpp文件一开始server: CppServer.cpp g++ -o CppServer -DHAVE_NETINET_IN_H -I${THRIFT_DIR} -I${BOOST_DIR} -L${LIB_DIR} /usr/local/lib/libthrift.a /usr/local/lib/libthriftnb.a /usr/local/lib/libthriftz.a CppServer.cpp ${GEN_SRC}总是报一大堆的错误,如:g++ -o CppServer -fPIC -DHAVE_NETINET_IN_H -I/usr/local/include/thrift -I/usr/local/boost/include/boost-1_33_1/ -L/usr/local/lib /usr/local/lib/libthrift.a /usr/local/lib/libthriftnb.a /usr/local/lib/libthriftz.a server.cpp WatchProxy.cpp watchproxy_types.cpp watchproxy_constants.cpp/tmp/ccLZYHik.o: In function `main':server.cpp:(.text+0x1de): undefined reference to `apache::thrift::transport::TServerSocket::TServerSocket(std::basic_string)'server.cpp:(.text+0x2f0): undefined reference to `apache::thrift::server::TSimpleServer::serve()'/tmp/ccLZYHik.o: In function `apache::thrift::server::TSimpleServer::~TSimpleServer()':server.cpp:(.text._ZN6apache6thrift6server13TSimpleServerD1Ev[apache::thrift::server::TSimpleServer::~TSimpleServer()]+0xf): undefined reference to `vtable for apache::thrift::server::TSimpleServer'后来改了一下编译语句的顺序g++ -o CppServer -DHAVE_NETINET_IN_H -I${THRIFT_DIR} -I${BOOST_DIR} server.cpp ${GEN_SRC} -L${LIB_DIR} /usr/local/lib/libthrift.a /usr/local/lib/libthriftnb.a /usr/local/lib/libthriftz.a就好了。因为我对编译方便也不懂,估计是将静态链接库文件放到前面的时候一些定义没找到,至于原因,还不清楚。
阅读(3115) | 评论(0) | 转发(0) |