安装的话可以百度搜索一下:muduo网络库使用手册
这里进行一些简要的总结
先贴一下muduo库github地址:
1.muduo采用CMake编译,首先安装CMake:
$ sudo apt-get install cmake
- 1
2.muduo依赖boost库:
$ sudo apt-get install libboostxxx-dev
- 1
3.muduo有三个非必须的依赖库,curl、c-ares DNS、google protobuf,如果安装了这三个库,cmake会多编译一些示例:
$ sudo apt-get install libcurl4-openssl-dev linc-ares-dev
$ sudo apt-get install protobuf-compiler libprotobuf-dev
- 1
- 2
muduo的编译(release版本):
./build.sh -j2 //编译库和它自带的例子,生成可执行文件和静态库文件,分别位于../buidl/release/{bin,lib}
./build.sh install //将头文件和静态库文件安装到../build/release-install/{include,lib}
- 1
- 2
编译完成后可运行其例子:bin/inspector_test,然后通过浏览器访问
http://xxx.xxx.xxx.xxx:12345/.其中,xxx.xxx.xxx.xxx为你的linuxIP
如何在自己项目中使用muduo:
muduo是静态链接的c++程序库,使用muduo库的时候,需要设置好头文件路径(例如../build/release-install/include)和库文件路径(例如../build/release-install/lib)并在编译时链接相应的静态库文件(-lmuduo_net -lmuduo_base)即可。
相应的示例Makefile地址:
compiling problems
1\
CMake错误No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment variable “CXX” or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
sudo apt-get update
sudo apt-get install -y build-essential