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
l
# 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
總結
以上是生活随笔為你收集整理的Linux环境网络库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TCMalloc:线程缓存的Malloc
- 下一篇: 位图排序