文档章节

【原创】源码编译libevent-2.0.21-stable生成库文件说明

摩云飞
 摩云飞
发布于 2015/08/20 15:59
字数 1464
阅读 2032
收藏 1

按照 README 中的说明,首先执行 configure
下面的输出信息是针对源码编译所在机器进行的检测

[root@Paxos libevent-2.0.21-stable]# ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
...
configure: creating ./config.status
config.status: creating libevent.pc
config.status: creating libevent_openssl.pc
config.status: creating libevent_pthreads.pc
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating test/Makefile
config.status: creating sample/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
[root@Paxos libevent-2.0.21-stable]#

接着,执行 make(只给出了我们关心的库文件)

[root@Paxos libevent-2.0.21-stable]# make
...
【生成 libevent-2.0.so.5.1.9 文件】
libtool: link: gcc -shared  -fPIC -DPIC  .libs/event.o .libs/evthread.o .libs/buffer.o .libs/bufferevent.o .libs/bufferevent_sock.o .libs/bufferevent_filter.o .libs/bufferevent_pair.o .libs/listener.o .libs/bufferevent_ratelim.o .libs/evmap.o .libs/log.o .libs/evutil.o .libs/evutil_rand.o .libs/strlcpy.o .libs/select.o .libs/poll.o .libs/epoll.o .libs/signal.o .libs/event_tagging.o .libs/http.o .libs/evdns.o .libs/evrpc.o   -lrt  -O2   -Wl,-soname -Wl,libevent-2.0.so.5 -o .libs/libevent-2.0.so.5.1.9
【建立 libevent.so 和 libevent-2.0.so.5 到 libevent-2.0.so.5.1.9 的软链接】
libtool: link: (cd ".libs" && rm -f "libevent-2.0.so.5" && ln -s "libevent-2.0.so.5.1.9" "libevent-2.0.so.5")
libtool: link: (cd ".libs" && rm -f "libevent.so" && ln -s "libevent-2.0.so.5.1.9" "libevent.so")
【生成 libevent.a 文件】
libtool: link: ar cru .libs/libevent.a  event.o evthread.o buffer.o bufferevent.o bufferevent_sock.o bufferevent_filter.o bufferevent_pair.o listener.o bufferevent_ratelim.o evmap.o log.o evutil.o evutil_rand.o strlcpy.o select.o poll.o epoll.o signal.o event_tagging.o http.o evdns.o evrpc.o
libtool: link: ranlib .libs/libevent.a
libtool: link: ( cd ".libs" && rm -f "libevent.la" && ln -s "../libevent.la" "libevent.la" )
【生成 libevent_core-2.0.so.5.1.9 文件】
libtool: link: gcc -shared  -fPIC -DPIC  .libs/event.o .libs/evthread.o .libs/buffer.o .libs/bufferevent.o .libs/bufferevent_sock.o .libs/bufferevent_filter.o .libs/bufferevent_pair.o .libs/listener.o .libs/bufferevent_ratelim.o .libs/evmap.o .libs/log.o .libs/evutil.o .libs/evutil_rand.o .libs/strlcpy.o .libs/select.o .libs/poll.o .libs/epoll.o .libs/signal.o   -lrt  -O2   -Wl,-soname -Wl,libevent_core-2.0.so.5 -o .libs/libevent_core-2.0.so.5.1.9
【建立 libevent_core.so 和 libevent_core-2.0.so.5 到 libevent_core-2.0.so.5.1.9 的软链接】
libtool: link: (cd ".libs" && rm -f "libevent_core-2.0.so.5" && ln -s "libevent_core-2.0.so.5.1.9" "libevent_core-2.0.so.5")
libtool: link: (cd ".libs" && rm -f "libevent_core.so" && ln -s "libevent_core-2.0.so.5.1.9" "libevent_core.so")
【生成 libevent_core.a 文件】
libtool: link: ar cru .libs/libevent_core.a  event.o evthread.o buffer.o bufferevent.o bufferevent_sock.o bufferevent_filter.o bufferevent_pair.o listener.o bufferevent_ratelim.o evmap.o log.o evutil.o evutil_rand.o strlcpy.o select.o poll.o epoll.o signal.o
libtool: link: ranlib .libs/libevent_core.a
libtool: link: ( cd ".libs" && rm -f "libevent_core.la" && ln -s "../libevent_core.la" "libevent_core.la" )
【生成 libevent_extra-2.0.so.5.1.9 文件】
libtool: link: gcc -shared  -fPIC -DPIC  .libs/event_tagging.o .libs/http.o .libs/evdns.o .libs/evrpc.o   -lrt  -O2   -Wl,-soname -Wl,libevent_extra-2.0.so.5 -o .libs/libevent_extra-2.0.so.5.1.9
【建立 libevent_extra.so 和 libevent_extra-2.0.so.5 到 libevent_extra-2.0.so.5.1.9 的软链接】
libtool: link: (cd ".libs" && rm -f "libevent_extra-2.0.so.5" && ln -s "libevent_extra-2.0.so.5.1.9" "libevent_extra-2.0.so.5")
libtool: link: (cd ".libs" && rm -f "libevent_extra.so" && ln -s "libevent_extra-2.0.so.5.1.9" "libevent_extra.so")
【生成 libevent_extra.a 文件】
libtool: link: ar cru .libs/libevent_extra.a  event_tagging.o http.o evdns.o evrpc.o
libtool: link: ranlib .libs/libevent_extra.a
libtool: link: ( cd ".libs" && rm -f "libevent_extra.la" && ln -s "../libevent_extra.la" "libevent_extra.la" )
【生成 libevent_pthreads-2.0.so.5.1.9 文件】
libtool: link: gcc -shared  -fPIC -DPIC  .libs/evthread_pthread.o   -lrt  -O2   -Wl,-soname -Wl,libevent_pthreads-2.0.so.5 -o .libs/libevent_pthreads-2.0.so.5.1.9
【建立 libevent_pthreads.so 和 libevent_pthreads-2.0.so.5 到 libevent_pthreads-2.0.so.5.1.9 的软链接】
libtool: link: (cd ".libs" && rm -f "libevent_pthreads-2.0.so.5" && ln -s "libevent_pthreads-2.0.so.5.1.9" "libevent_pthreads-2.0.so.5")
libtool: link: (cd ".libs" && rm -f "libevent_pthreads.so" && ln -s "libevent_pthreads-2.0.so.5.1.9" "libevent_pthreads.so")
【生成 libevent_pthreads.a 文件】
libtool: link: ar cru .libs/libevent_pthreads.a  evthread_pthread.o
libtool: link: ranlib .libs/libevent_pthreads.a
libtool: link: ( cd ".libs" && rm -f "libevent_pthreads.la" && ln -s "../libevent_pthreads.la" "libevent_pthreads.la" )
【生成 libevent_openssl-2.0.so.5.1.9 文件】
libtool: link: gcc -shared  -fPIC -DPIC  .libs/bufferevent_openssl.o   -lssl -lcrypto -lrt  -O2   -Wl,-soname -Wl,libevent_openssl-2.0.so.5 -o .libs/libevent_openssl-2.0.so.5.1.9
【建立 libevent_openssl.so 和 libevent_openssl-2.0.so.5 到 libevent_openssl-2.0.so.5.1.9 的软链接】
libtool: link: (cd ".libs" && rm -f "libevent_openssl-2.0.so.5" && ln -s "libevent_openssl-2.0.so.5.1.9" "libevent_openssl-2.0.so.5")
libtool: link: (cd ".libs" && rm -f "libevent_openssl.so" && ln -s "libevent_openssl-2.0.so.5.1.9" "libevent_openssl.so")
【生成 libevent_openssl.a 文件】
libtool: link: ar cru .libs/libevent_openssl.a  bufferevent_openssl.o
libtool: link: ranlib .libs/libevent_openssl.a
libtool: link: ( cd ".libs" && rm -f "libevent_openssl.la" && ln -s "../libevent_openssl.la" "libevent_openssl.la" )
...
[root@Paxos libevent-2.0.21-stable]#

最后指定 make install 命令

[root@Paxos libevent-2.0.21-stable]# make install
...(将库文件安装到系统目录中)
...(变更权限和为 .a 文件增加 index)
[root@Paxos libevent-2.0.21-stable]#

此时可以看到生成的文件已经位于系统中了

[root@Paxos ~]# updatedb
[root@Paxos ~]# locate libevent
...
/usr/local/lib/libevent-2.0.so.5
/usr/local/lib/libevent-2.0.so.5.1.9
/usr/local/lib/libevent.a
/usr/local/lib/libevent.la
/usr/local/lib/libevent.so
/usr/local/lib/libevent_core-2.0.so.5
/usr/local/lib/libevent_core-2.0.so.5.1.9
/usr/local/lib/libevent_core.a
/usr/local/lib/libevent_core.la
/usr/local/lib/libevent_core.so
/usr/local/lib/libevent_extra-2.0.so.5
/usr/local/lib/libevent_extra-2.0.so.5.1.9
/usr/local/lib/libevent_extra.a
/usr/local/lib/libevent_extra.la
/usr/local/lib/libevent_extra.so
/usr/local/lib/libevent_openssl-2.0.so.5
/usr/local/lib/libevent_openssl-2.0.so.5.1.9
/usr/local/lib/libevent_openssl.a
/usr/local/lib/libevent_openssl.la
/usr/local/lib/libevent_openssl.so
/usr/local/lib/libevent_pthreads-2.0.so.5
/usr/local/lib/libevent_pthreads-2.0.so.5.1.9
/usr/local/lib/libevent_pthreads.a
/usr/local/lib/libevent_pthreads.la
/usr/local/lib/libevent_pthreads.so
/usr/local/lib/pkgconfig/libevent.pc
/usr/local/lib/pkgconfig/libevent_openssl.pc
/usr/local/lib/pkgconfig/libevent_pthreads.pc
[root@Paxos ~]#

将上面的 make 输出进行整理后,可以知道编译各个库的时候都包含了哪些内容,使用哪些选项

【生成 libevent-2.0.so.5.1.9 文件】

libtool: link: gcc -shared  -fPIC -DPIC  
.libs/event.o 
.libs/evthread.o 
.libs/buffer.o 
.libs/bufferevent.o 
.libs/bufferevent_sock.o 
.libs/bufferevent_filter.o 
.libs/bufferevent_pair.o 
.libs/listener.o 
.libs/bufferevent_ratelim.o 
.libs/evmap.o 
.libs/log.o 
.libs/evutil.o 
.libs/evutil_rand.o 
.libs/strlcpy.o 
.libs/select.o 
.libs/poll.o 
.libs/epoll.o 
.libs/signal.o 
.libs/event_tagging.o 
.libs/http.o 
.libs/evdns.o 
.libs/evrpc.o  
-lrt  -O2   -Wl,-soname -Wl,libevent-2.0.so.5 -o .libs/libevent-2.0.so.5.1.9

【生成 libevent_core-2.0.so.5.1.9 文件】

libtool: link: gcc -shared  -fPIC -DPIC  
.libs/event.o 
.libs/evthread.o 
.libs/buffer.o 
.libs/bufferevent.o 
.libs/bufferevent_sock.o 
.libs/bufferevent_filter.o 
.libs/bufferevent_pair.o 
.libs/listener.o 
.libs/bufferevent_ratelim.o 
.libs/evmap.o 
.libs/log.o 
.libs/evutil.o 
.libs/evutil_rand.o 
.libs/strlcpy.o 
.libs/select.o 
.libs/poll.o 
.libs/epoll.o 
.libs/signal.o 
-lrt  -O2   -Wl,-soname -Wl,libevent_core-2.0.so.5 -o .libs/libevent_core-2.0.so.5.1.9

【生成 libevent_extra-2.0.so.5.1.9 文件】

libtool: link: gcc -shared  -fPIC -DPIC  
.libs/event_tagging.o 
.libs/http.o 
.libs/evdns.o 
.libs/evrpc.o 
-lrt  -O2   -Wl,-soname -Wl,libevent_extra-2.0.so.5 -o .libs/libevent_extra-2.0.so.5.1.9

【生成 libevent_pthreads-2.0.so.5.1.9 文件】

libtool: link: gcc -shared  -fPIC -DPIC  
.libs/evthread_pthread.o  
-lrt  -O2   -Wl,-soname -Wl,libevent_pthreads-2.0.so.5 -o .libs/libevent_pthreads-2.0.so.5.1.9

【生成 libevent_openssl-2.0.so.5.1.9 文件】
libtool: link: gcc -shared  -fPIC -DPIC  
.libs/bufferevent_openssl.o  
-lssl -lcrypto -lrt  -O2   -Wl,-soname -Wl,libevent_openssl-2.0.so.5 -o .libs/libevent_openssl-2.0.so.5.1.9

可以看出,从库文件所包含内容上来说
libevent  = libevent_core + libevent_extra

而 libevent_pthreads 和 libevent_openssl 是两个专门用途的库。

网上有人给出如下使用建议:

  • libevent 2.0 版本之后,建议不要再直接链接 libevent 库,而应根据需要链接 libevent_core 和 libevent_extra 等库
  • libevent_core 提供了 event_base 、evbuffer 、bufferevent 、utility 等常用方法
  • libevent_extra 提供 HTTP 、DNS ,以及 RPC 等高级功能
  • 如果以多线程方式使用 libevent ,则还需要链接 libevent_pthreads 库
  • 如果用到 ssl,则需要再链接 libevent_openssl 库

 

 

 

 

© 著作权归作者所有

共有 人打赏支持
摩云飞
粉丝 368
博文 534
码字总数 952694
作品 0
徐汇
程序员
memcached源码安装

memcached源码安装 下载libevent: wget https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz 下载memcached: wget http://memcached.org/files/memcache......

运维的名义
2017/10/01
0
0
libevent在window下编译

此文只因为自己经历所写,并非转帖或原创一说,因为大致编译方法都大同小异的。 环境: window 10 工具: visual studio 2013 版本: libevent-2.0.22-statble 过程: $VCPATH : ...vs2013v...

TemiCai
2015/09/08
66
0
vc编译libevent

  假设 Visual Studio 2005 的安装路径为“D:Program FilesMicrosoft Visual Studio 8”,Libevent 2.0.10 解压后的路径为“D:libevent-2.0.10-stable”。   一、编译生成 Libevent 2.0...

姿势喵
02/10
0
0
在Linux下编译安装memcached

一.在编译安装之前,先安装系统所需要的相关库文件 #yum -y install gcc gcc-c++ make cmake libtool autoconf libaio 二.下载相应的依赖库和memcached源码包 1.从http://libevent.org/下载l...

gdp1088
2017/08/08
0
0
在Linux下编译安装memcached

一.在编译安装之前,先安装系统所需要的相关库文件 #yum -y install gcc gcc-c++ make cmake libtool autoconf libaio 二.下载相应的依赖库和memcached源码包 1.从http://libevent.org/下载l...

gdp1088
06/29
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Python深体验,常见的数据处理方式(必须要懂的)

1.缺失值处理 - 拉格朗日插值法 input_file数据文件内容(存在部分缺失值): from scipy.interpolate import lagrangeimport pandas as pdimport numpy as npinput_file = './dat...

无也Python
26分钟前
2
0
Spring MVC注解故障追踪记

Spring MVC是美团点评很多团队使用的Web框架。在基于Spring MVC的项目里,注解的使用几乎遍布在项目中的各个模块,有Java提供的注解,如:@Override、@Deprecated等;也有Spring提供的注解,...

Skqing
28分钟前
4
0
区块链入门教程以太坊源码分析cmd包分析

  兄弟连区块链入门教程以太坊源码分析cmd包分析。 ### cmd包概述 * geth 主要Ethereum CLI客户端。它是Ethereum网络(eth主网,测试网络或私有网)的入口点,使用此命令可以使节点作为ful...

兄弟连区块链入门教程
29分钟前
1
0
@Autowired 报红线

代码可正常跑,不过红线看着有点难受,解决方案 使用@Autowired(required=false) 或者@Resource. 这两者区别网上一大堆

斩神魂
35分钟前
3
0
DataTable中检索信息 (C#)

C#_从DataTable中检索信息 存在于内存中的虚拟表DataTable,绑定在数据显示控件后,如果想在再检索其中某些信息,可以利用DataTable.Select方法进行检索,避免了重复的读取数据库。Select方法...

CS-CS01
43分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部