链接过程如找不到thrift.so文件 请在
/etc/ld.so.conf.d/ 目录下添加如下文件 内容为so文件所在位置
thrift.conf ->/usr/local/lib
libevent.conf ->/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 运行后图片如下
可以看到thrift 通过libevent 成功调用 epool