libevent + static link

libevent をスタティックリンクでコンパイルする方法をメモ。

標準の configure オプションで shared, static ともに有効になってる。

なので configure オプションは変更なし。

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

shared が気になるときは

  
./configure --prefix=/usr/local/libevent --disable-shared  

とすればOK。

  
make  
make install  

これでインストールまで完了。

続いてMakefile

main.o の後ろに /usr/local/libevent/lib/libevent.a をひっつける。

環境によっては make 時にエラーが出るっぽい。
CentOS5 で試したときは LIBS に -lrt を追加してあげないとエラーになった。

Makefile

一応 サンプル