muduo库安装

一、简介

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例子:

原文地址:https://www.cnblogs.com/lit10050528/p/4887282.html