$./configure $make #sudo make install
anonymalias@anonymalias-Rev-1-0:~/download/thrift-0.9.1$./configure ...... thrift 0.9.1 Building C++ Library ......... : yes Building C (GLib) Library .... : no Building Java Library ........ : no Building C# Library .......... : no Building Python Library ...... : yes Building Ruby Library ........ : no Building Haskell Library ..... : no Building Perl Library ........ : no Building PHP Library ......... : no Building Erlang Library ...... : no Building Go Library .......... : no Building D Library ........... : no C++ Library: Build TZlibTransport ...... : yes Build TNonblockingServer .. : yes Build TQTcpServer (Qt) .... : no Python Library: Using Python .............. : /usr/bin/python If something is missing that you think should be present, please skim the output of configure to find the missing component. Details are present in config.log.
method1: 解决的方法时直接从Github(git://git.apache.org/thrift.git)上git clone 源码,先运行./bootstrap.sh,在按照configure安装。 method2: 可以将已经编译的test/cpp/*.o复制到test/cpp/.libs后,继续编译就可以了 cp test/cpp/*.o test/cpp/.libs/
struct message
{
1:i32 seqId,
2:string content
}
service serDemo
{
void put(1:message msg)
}
class serDemoHandler : virtual public serDemoIf {
public:
serDemoHandler() {
// Your initialization goes here
}
void put(const message& msg) {
// Your implementation goes here
printf("receive message: id: %d, content: %s\n", msg.seqId, msg.content.c_str());
}
// -------------------------替换成对应service名字的.h 文件------------------------
#include "SerDemo.h"
//------------------------------------------------------------------------------
#include <transport/TSocket.h>
#include <transport/TBufferTransports.h>
#include <protocol/TBinaryProtocol.h>
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using boost::shared_ptr;
int main(int argc, char **argv) {
boost::shared_ptr<TSocket> socket(new TSocket("localhost", 9090));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
transport->open();
// ----------------------------我们的代码写在这里------------------------------
message msg;
msg.seqId = 1;
msg.content = "client message";
client.put(msg);
//--------------------------------------------------------------------------
transport->close();
return 0;
}
anonymalias@anonymalias-Rev-1-0:~/code/thriftSerDemo/gen-cpp$ ./server receive message: id: 1, content: client message
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有