打赏
禅在心中
东风夜放花千树,更吹落、星如雨。宝马雕车香满路。凤箫声动,玉壶光转,一夜鱼龙舞。 蛾儿雪柳黄金缕,笑语盈盈暗香去。众里寻他千百度,蓦然回首,那人却在,灯火阑珊处。

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

 

posted on 2017-11-05 17:04  禅在心中  阅读(656)  评论(0编辑  收藏  举报