一、簡介
Muduo(木鐸)是基於 Reactor 模式的網絡庫。
二、安裝
從github庫下載源碼安裝:https://github.com/chenshuo/muduo
muduo依賴了很多的庫,所以在安裝muduo之前應該安裝這些庫,包括:curl、c-ares、protobuf。
前面兩個在centos6.2可以使用yum安裝,protobuf只能源碼安裝了,參見這篇文章。
yum install libcurl-devel yum install c-ares-devel
在muduo目錄下執行:./build.sh -j2
中間遇到了一些問題:
在net/protorpc/RpcChannel.cc文件中NewCallback未定義,以及examples/protobuf/rpc/client.cc文件中NewCallback未定義,最后在github上提了個issue給碩哥,經過他的指導注釋了一下CMakfiles的內容,然后編譯通過。
https://github.com/chenshuo/muduo/blob/master/examples/CMakeLists.txt#L39
https://github.com/chenshuo/muduo/blob/master/muduo/net/CMakeLists.txt#L65
三、使用
然后運行test例子: