## 环境搭建 ### [](http://127.0.0.1:3334/mdEditor/#%E4%B8%80-%E7%B3%BB%E7%BB%9F%E5%BA%93%E5%AE%89%E8%A3%85)一、系统库安装 centos查看系统版本 ~~~ cat /etc/redhat-release uname -a ~~~ libc版本查看 /lib/libc.so.6 有时:/lib/x86-64-linux/libc.so.6 ~~~ ldd --version ~~~ 系统及环境要求: * windows7及以上版本,centos 7 x64 * visual studio 2017 必须安装的visual c++ 组件 * cmake 3.5及以上版本 * windows和linux 必须支持c++11 **1.工具库安装** 安装软件源 ~~~ yum install -y epel-release ~~~ 安装开发工具 ~~~ yum group install -y "Development Tools" ~~~ **2.cmake安装** 如果wget没有安装,执行以下命令: ~~~ yum install wget -y yum install vim -y yum install lrzsz -y ~~~ **3.7z安装使用** ~~~ yum install p7zip p7zip-plugins ~~~ 压缩: ~~~ 7z a heed.7z sputnik ~~~ 解压: ~~~ 7z x heed.7z ~~~ **3.cmake 安装** 参考地址:[https://blog.csdn.net/llwy1428/article/details/95473542](https://blog.csdn.net/llwy1428/article/details/95473542) ~~~shell # 步骤如下# 移除旧版yum remove cmake -ywget https://cmake.org/files/v3.14/cmake-3.14.5.tar.gztar zxvf cmake-3.14.5.tar.gz cd cmake-3.14.5./configure --prefix=/usr/local/cmakemake && make installln -s /usr/local/cmake/bin/cmake /usr/bin/cmakevim /etc/profileexport CMAKE_HOME=/usr/local/cmakeexport PATH=$PATH:$CMAKE_HOME/binsource /etc/profilecmake -version ~~~ **3.g++7 安装** 参考地址:[https://blog.csdn.net/linuxheik/article/details/83039273](https://blog.csdn.net/linuxheik/article/details/83039273) ~~~shell sudo yum install centos-release-scl -ysudo yum install devtoolset-7 -yscl enable devtoolset-7 bashsource /opt/rh/devtoolset-7/enablegcc --version ~~~ **4.htop 性能** ~~~shell yum install epel-release -yyum install htop -y ~~~ ### [](http://127.0.0.1:3334/mdEditor/#%E4%BA%8C-%E4%BE%9D%E8%B5%96%E5%BA%93%E5%AE%89%E8%A3%85)二、依赖库安装 * [x] boost 1.66.0 * [x] windows (直接下载) * [x] linux * [x] spdlog 1.8.1 * [x] windows * [x] linux * [x] tinyxml2 * [x] windows * [x] linux * [x] librdkafka * [x] windows * [x] linux * [x] rapidjson * [x] windows * [x] linux * [ ] xredis * [x] windows * [x] linux * [ ] mysql-connector-c-6.1.11 * [x] windows * [x] linux **目录定义** windows ~~~ 库目录:D:/local/third/lib 头文件目录:D:/local/third/include ~~~ linux ~~~ 库目录:/root/local/third/lib 头文件目录:/root/local/third/include ~~~ **1.boost 库** * windows 直接下载 官方地址:[点击跳转](https://sourceforge.net/projects/boost/files/boost-binaries/) * linux 源码编译 ~~~ ./bootstrap.sh --prefix=/root/local/third ./b2 install ~~~ **2\. spdlog 库** * windows 源码编译 1. 生成sln工程 ~~~ cd XXX mkdir build cmake .. -G "Visual Studio 15 2017 Win64" ~~~ 2. 打开**XXX.sln**工程 3. 选择**Release****X64**选项进行编译 4. 拷贝生成的**spdlog.lib**到库目录 5. 拷贝头文件到头文件目录 * linux 源码编译 1. 编译安装库 ~~~ cd XXX mkdir build cmake .. -DCMAKE_INSTALL_PREFIX=/root/local/third -DCMAKE_INSTALL_INCLUDEDIR=/root/local/third/include -DCMAKE_INSTALL_LIBDIR=/root/local/third/lib make && make install ~~~ **hiredis** linux 源码编译 ~~~ export PREFIX=/root/local/third cd XXX make && make install ~~~ **librdkafka** linux : > 致命错误:openssl/ssl.h:没有那个文件或目录 CentOS系统执行以下命令 ~~~ sudo yum install openssl-devel -y ~~~ Ubuntu系统执行以下命令 ~~~ sudo apt-get install libssl-dev ~~~ 成功安装openssl后,执行下面的命令 ~~~ cd XXX ./configure --prefix=/root/local/third make && make install ~~~ **tinyxml2** * linux 源码编译 1. 编译安装库 ~~~ cd XXX mkdir build cmake .. -DCMAKE_INSTALL_PREFIX=/root/local/third -DCMAKE_INSTALL_INCLUDEDIR=/root/local/third/include -DCMAKE_INSTALL_LIBDIR=/root/local/third/lib make && make install ~~~ **rapidjson** * linux 源码编译 1. 编译安装库 ~~~ cd XXX mkdir build cmake .. -DCMAKE_INSTALL_PREFIX=/root/local/third -DCMAKE_INSTALL_INCLUDEDIR=/root/local/third/include -DCMAKE_INSTALL_LIBDIR=/root/local/third/lib make && make install ~~~ **mysql-connector-c-6.1.11** * 编译安装库 1. linux 源码编译 ~~~ cd XXX mkdir build cmake .. -DCMAKE_INSTALL_PREFIX=/root/local/third -DCMAKE_INSTALL_INCLUDEDIR=/root/local/third/include -DCMAKE_INSTALL_LIBDIR=/root/local/third/lib make && make install ~~~ 2. windows 源码编译 ~~~ cd XXX 创建 build 目录 cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=D:/local/third -DCMAKE_INSTALL_INCLUDEDIR=D:/local/third/include -DCMAKE_INSTALL_LIBDIR=D:/local/third/lib make && make install ~~~ ## [](http://127.0.0.1:3334/mdEditor/#%E7%B3%BB%E7%BB%9F%E9%85%8D%E7%BD%AE)系统配置 **1.依赖库拷贝** ~~~shell # 假设在192.168.28.24机器操作scp -r /usr/local/boost root@192.168.28.22:/usr/local/boostscp -r /usr/local/lib64 root@192.168.28.22:/usr/local/lib64 ~~~ **2.平台生成项目** **windows :** ~~~ cd demo mkdir build ~~~ 标准生成项目: ~~~ cmake .. -G "Visual Studio 15 2017 Win64" ~~~ 加入boost库生成项目: ~~~ cmake .. -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT=D:/local/boost_1_67_0 -DBOOST_INCLUDEDIR=D:/local/boost_1_67_0/boost -DBOOST_LIBRARYDIR=D:/local/boost_1_67_0/lib64-msvc-14.1 -D CMAKE_BUILD_TYPE=Release -D CMAKE_INCLUDE_PATH=D:/local/third/include -D CMAKE_LIBRARY_PATH=D:/local/third/lib ~~~ 启动项目 ~~~ 打开 demo.sln ~~~ **linux:** ~~~ cd demo mkdir build ~~~ 标准生成项目: ~~~ cmake .. ~~~ 加入boost库生成项目: ~~~ cmake .. -D BOOST_ROOT=/root/local/third -D BOOST_INCLUDEDIR=/root/local/third/boost -D BOOST_LIBRARYDIR=/root/local/third/lib -D CMAKE_BUILD_TYPE=Release -D CMAKE_INCLUDE_PATH=/root/local/third/include -D CMAKE_LIBRARY_PATH=/root/local/third/lib ~~~ 执行编译 ~~~ make ~~~ ## [](http://127.0.0.1:3334/mdEditor/#%E6%BC%94%E7%A4%BA%E6%A1%88%E4%BE%8B)演示案例 #### [](http://127.0.0.1:3334/mdEditor/#%E4%BB%A3%E7%A0%81%E7%BC%96%E8%AF%91)代码编译 **1.克隆仓库** ~~~shell git clone ssh://git@192.168.28.24:10022/mint/engine.gitgit pull origin master ~~~ **2.编译生成** ~~~shell cd enginemkdir buildcd buildcmake ..make ~~~