Linux下使用thrfit

1、安装boost、thrfit

2、生成gen-cpp

3、编译其中的server,方法为:

(1)、直接使用g++编译

g++ -o server HelloWorld.cpp helloworld_constants.cpp helloworld_types.cpp HelloWorld_server.skeleton.cpp -I/usr/local/include/thrift -L/usr/local/lib -lthfit

运行生成server,有可能出现找不到链接库的情况

./server

./server:error while loading shared libraries: libthrift-0.10.0.so: cannot open shared object file: No such file or directory

解决方法:

在/etc/ld.so.conf下面添加一行/usr/local/lib,即libthrfit-0.10.0.so所在的路径。

ldconfig更新配置即可。

 

对于使用g++编译的方法,可以写一个shell脚本,这样就不用每次都在命令行输入了。

脚本代码:

#!/bin/bash

name=server#注意没有空格
echo $name

rm $name

g++ -o $name \
HelloWorld.cpp \
helloworld_constants.cpp \
helloworld_types.cpp \
HelloWorld_server.skeleton.cpp \
-I/usr/local/include/thrift \
-L/usr/local/lib -lthfit

  (2)、使用Qt编译

如果系统装了Qt,可以利用该开发工具进行相关开发

首先通过qmake -project或自己创建.pro文件,在其中添加依赖文件:

INCLUDEPATH += -I/usr/local/include/thrift

LIBS += -L/usr/local/lib -lthrift

 

转载于:https://www.cnblogs.com/pinking/p/7787848.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值