前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >Linux下使用thrfit

Linux下使用thrfit

作者头像
全栈程序员站长
发布2022-07-09 12:20:24
发布2022-07-09 12:20:24
2.6K00
代码可运行
举报
运行总次数:0
代码可运行

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脚本,这样就不用每次都在命令行输入了。

脚本代码:

代码语言:javascript
代码运行次数:0
复制
#!/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://javaforall.cn/119489.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021年11月,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档