---
title: "thrift TNonblockingServer 涉及点"
author: "fenglin"
date: "2011-02-13T17:08:58Z"
tags: []
categories: ["编程语言"]
slug: "thrift-tnonblockingserver"
draft: false
lastmod: "2011-02-13T17:14:29Z"
id: 905295
url: "https://fenglin.iteye.com/blog/905295"
---

链接过程如找不到thrift.so文件 请在

/etc/ld.so.conf.d/ 目录下添加如下文件 内容为so文件所在位置

 

thrift.conf  -&gt;/usr/local/lib

libevent.conf -&gt;/usr/lib

 

保存后 记得/sbin/ldconfig -v 更新缓存

 

TNonblockingServer 连接过程中涉及到thriftnb.so libevent.so 少一个都不行

 

thriftnb.so位于/usr/local/lib下面

libevent 在/usr/lib下面

 

如出现下面的错误

/usr/local/lib/libthriftnb.so: undefined reference to \`event\_get\_version'  
/usr/local/lib/libthriftnb.so: undefined reference to \`event\_set'  
/usr/local/lib/libthriftnb.so: undefined reference to \`event\_base\_free'  
/usr/local/lib/libthriftnb.so: undefined reference to \`event\_get\_method'  
/usr/local/lib/libthriftnb.so: undefined reference to \`event\_del'  
/usr/local/lib/libthriftnb.so: undefined reference to \`event\_add'  
/usr/local/lib/libthriftnb.so: undefined reference to \`event\_init'  
/usr/local/lib/libthriftnb.so: undefined reference to \`event\_base\_set'  
/usr/local/lib/libthriftnb.so: undefined reference to \`event\_base\_loop'

 

说明没有找到libevent 先确认libevent正确安装

 

然后在G++链接语句这样

 

g++ -L /usr/local/lib -L /usr/lib -levent -lthrift -lthriftnb \*.o -o UserService\_serve

 

 

TNonblockingServer 运行后图片如下

 

![](http://dl.iteye.com/upload/attachment/415512/83558432-49b9-3221-b676-ec20fbc26185.jpg)r

 

可以看到thrift 通过libevent 成功调用 epool