下載並安裝libevent開發庫詳細步驟

readyao發表於2016-02-12

1、下載libevent開發庫原始碼:

在終端輸入:git clone https://github.com/yaoxiaokui/libevent-2.0.21-stable.git

輸出為下面所示則表示克隆成功。在當前目錄下可以檢視到libevent庫的目錄為libevent-2.0.21-stable

正克隆到 'libevent-2.0.21-stable'...
remote: Counting objects: 338, done.
remote: Compressing objects: 100% (230/230), done.
remote: Total 338 (delta 100), reused 338 (delta 100), pack-reused 0
接收物件中: 100% (338/338), 3.15 MiB | 48.00 KiB/s, done.
處理 delta 中: 100% (100/100), done.
檢查連線... 完成。

2、進入libevent-2.0.21-stable目錄

輸入: cd libevent-2.0.21-stable


3、配置安裝路徑

輸入: ./configure -prefix=/usr


4、編譯並安裝

輸入: make

輸入: make install


5、測試安裝是否成功

輸入: ls -al /usr/lib | grep libevent

如果輸出為下所示則表示安裝成功

lrwxrwxrwx   1 root root           21  2月 12 14:54 libevent-2.0.so.5 -> libevent-2.0.so.5.1.9
-rwxr-xr-x   1 root root      1192544  2月 12 14:54 libevent-2.0.so.5.1.9
-rw-r--r--   1 root root      2308410  2月 12 14:54 libevent.a
lrwxrwxrwx   1 root root           26  2月 12 14:54 libevent_core-2.0.so.5 -> libevent_core-2.0.so.5.1.9
-rwxr-xr-x   1 root root       711281  2月 12 14:54 libevent_core-2.0.so.5.1.9
-rw-r--r--   1 root root      1431546  2月 12 14:54 libevent_core.a
-rwxr-xr-x   1 root root          974  2月 12 14:54 libevent_core.la
lrwxrwxrwx   1 root root           26  2月 12 14:54 libevent_core.so -> libevent_core-2.0.so.5.1.9
lrwxrwxrwx   1 root root           27  2月 12 14:54 libevent_extra-2.0.so.5 -> libevent_extra-2.0.so.5.1.9
-rwxr-xr-x   1 root root       507551  2月 12 14:54 libevent_extra-2.0.so.5.1.9
-rw-r--r--   1 root root       876936  2月 12 14:54 libevent_extra.a
-rwxr-xr-x   1 root root          981  2月 12 14:54 libevent_extra.la
lrwxrwxrwx   1 root root           27  2月 12 14:54 libevent_extra.so -> libevent_extra-2.0.so.5.1.9
-rwxr-xr-x   1 root root          939  2月 12 14:54 libevent.la
lrwxrwxrwx   1 root root           30  2月 12 14:54 libevent_pthreads-2.0.so.5 -> libevent_pthreads-2.0.so.5.1.9
-rwxr-xr-x   1 root root        23987  2月 12 14:54 libevent_pthreads-2.0.so.5.1.9
-rw-r--r--   1 root root        21990  2月 12 14:54 libevent_pthreads.a
-rwxr-xr-x   1 root root         1002  2月 12 14:54 libevent_pthreads.la
lrwxrwxrwx   1 root root           30  2月 12 14:54 libevent_pthreads.so -> libevent_pthreads-2.0.so.5.1.9
lrwxrwxrwx   1 root root           21  2月 12 14:54 libevent.so -> libevent-2.0.so.5.1.9

6、使用該庫

編譯的時候要加上   -levent 選項。

例如:g++ -o libevent_helloworld libevent_helloworld.cpp -levent


相關文章