下载安装muduo 并完成环境配置
首先再GitHub找到muduo,查看clone的链接,使用git命令clone到本地:
git clone https://github.com/chenshuo/muduo.git
muduo现在有1.0和2.0两个版本可选,1.0版本编译前需要下载boost,2.0不需要
安装boost:
yum install boost yum install boost-devel yum install boost-doc
编译安装muduo:
进入下载下载好的目录:
[root@VM-8-14-centos muduo_2]# cd muduo-2.0.2/ [root@VM-8-14-centos muduo-2.0.2]# ls BUILD.bazel ChangeLog CMakeLists.txt contrib License patches WORKSPACE build.sh ChangeLog2 compile_commands.json examples muduo README
运行下面两个操作:
./build.sh -j2 ./build.sh install
上述操作在大部分关于muduo安装的博客都可以看到,下面是安装完了怎么使用:
首先将相关include与lib加入/usr/local:
安装完在muduo同级目录下会有一个build目录,进入该目录并执行以下操作:
[root@VM-8-14-centos muduo_2]# cd build/release-install-cpp11/include/ [root@VM-8-14-centos include]# ls muduo [root@VM-8-14-centos include]# cp -r muduo/ /usr/local/include/ [root@VM-8-14-centos include]# cd ../lib/ [root@VM-8-14-centos lib]# ls libmuduo_base.a libmuduo_http.a libmuduo_inspect.a libmuduo_net.a [root@VM-8-14-centos lib]# cp * /usr/local/lib/
测试是否配置完成:
进入muduo给出的examples文件夹中,找到测试用例,自己编译生成试试,下面时echo这个示例:
g++ echo.cc main.cc -o echo -lmuduo_base -lmuduo_net -lpthread -std=c++11
转载请注明出处