Linux环境网络库

安装libevent

官网:http://libevent.org/   

书籍:http://www.wangafu.net/~nickm/libevent-book/

Libevent参考手册翻译:http://blog.csdn.net/laoyi19861011/article/category/831215

Libevent参考手册翻译增加:http://blog.sina.com.cn/s/articlelist_1457448730_3_1.html

源码分析:http://www.cnblogs.com/hustcat/archive/2010/08/31/1814022.html

libevent

# wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

# tar xzfv  libevent-2.0.21-stable.tar.gz

# cd libevent-2.0.21-stable

# ./configure -prefix=/usr/local/libevent

# make && make install


如果其他调用event的程序安装报错

error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

解决办法:

先得到libevent位置

# whereis libevent 

[root@localhost test]#  whereis libevent
libevent: /usr/local/libevent


On a 32 bit system:

# ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5

On a 64 bit system:

# ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5


如果提示“创建符号链接 "/usr/lib64/libevent-2.0.so.5": 文件已存在”那么就是之前安装过,所以只要删除之前的即可

# rm -f libevent-2.0.so.5

重新链接即可


其他解决方法:

那就表示系统不知道xxx.so 放在哪个目录下。
这个时候就要在/etc/ld.so.conf中加入xxx.so所在的目录。
一般而言,有很多so档会在/usr/local/lib这个目录下,所以在/etc/ld.so.conf中加入/usr/local/lib这一行,可以解决此问题。
将 /etc/ld.so.conf存档后,还要执行「/sbin/ldconfig –v」来更新一下才会生效。


如果libevent安装是自定义-prefix=/usr/local/libevent

# gcc socket.c -o socket -Wl,-rpath,/usr/local/libevent/lib/ -L/usr/local/libevent/lib/ -levent -I/usr/local/libevent/include/

如果libevent安装是无-prefix

# gcc socket.c -o socket -levent 


可以使用ldd查看动态链接库调用:



参考:GCC设定include和库路径



参考实例:

https://github.com/mike-zhang/testCodes

https://github.com/jasonish/libevent-examples

http://ishbits.googlecode.com/svn-history/r5/trunk/libevent_echosrv/

http://blog.linuxphp.org/archives/1482/

=============================================

libdatrie

http://linux.thai.net/~thep/datrie/datrie.html

#wget ftp://linux.thai.net/pub/ThaiLinux/software/libthai/libdatrie-0.2.4.tar.gz

# tar zxvf libdatrie-0.2.4.tar.gz

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值