# tutorial_cpp **Repository Path**: joey-fudan/tutorial_cpp ## Basic Information - **Project Name**: tutorial_cpp - **Description**: cpp模块测试用例 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-13 - **Last Updated**: 2021-04-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: Cpp ## README # tutorial_cpp #### 介绍 cpp模块测试用例, 注意全部选择静态库编译. 测试环境 (确认安装有 Development Tools 工具集和 devtoolset-9): - CentOS 7.6 64-bit - gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) - cmake version 3.17.5 #### 安装教程 ### 基础库(按顺序安装) 1. 编译 [zlib](https://gitee.com/jzhufudan/zlib/tree/v1.2.11/) ```shell git clone https://gitee.com/jzhufudan/zlib --depth 1 --branch v1.2.11 cd zlib && mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX=~/install make -j && make test && make install ``` 2. 编译 [openssl](https://gitee.com/jzhufudan/openssl/tree/OpenSSL_1_1_1-stable/) ```shell git clone https://gitee.com/jzhufudan/openssl --depth 1 --branch OpenSSL_1_1_1-stable cd openssl && ./config --prefix=$HOME/install --openssldir=$HOME/install --with-zlib-include=$HOME/install/include --with-zlib-lib=$HOME/install/lib zlib no-shared make -j && make test && make install_sw ``` 3. 编译 [curl](https://gitee.com/jzhufudan/curl/tree/curl-7_74_0/), 依赖工具`autoconf automake` ```shell git clone https://gitee.com/jzhufudan/curl --depth 1 --branch curl-7_74_0 cd curl && ./buildconf && env PKG_CONFIG_PATH=$HOME/install/lib/pkgconfig CPPFLAGS="-I${HOME}/install/include" LDFLAGS="-L${HOME}/install/lib" ./configure --prefix=$HOME/install --disable-shared --disable-manual --disable-debug make -j && make test && make install ``` 4. 编译 [hiredis](https://gitee.com/jzhufudan/hiredis/tree/v0.14.1/) ```shell git clone https://gitee.com/jzhufudan/hiredis --depth 1 --branch v0.14.1 cd hiredis && make PREFIX=~/install && make PREFIX=~/install install ``` 5. 编译 [redis-plus-plus](https://gitee.com/jzhufudan/redis-plus-plus/tree/1.2.3/) ```shell git clone https://gitee.com/jzhufudan/redis-plus-plus --depth 1 --branch 1.2.3 cd redis-plus-plus && mkdir build && cd build cmake .. -DCMAKE_PREFIX_PATH=~/install -DCMAKE_INSTALL_PREFIX=~/install -DREDIS_PLUS_PLUS_BUILD_SHARED=OFF -DREDIS_PLUS_PLUS_CXX_STANDARD=17 make -j && make install ``` ### 其余库 包含 - [fmt](https://gitee.com/jzhufudan/fmt/tree/7.1.3/) - [googletest](https://gitee.com/jzhufudan/googletest/tree/release-1.10.0/) - [rapidjson](https://gitee.com/jzhufudan/rapidjson/tree/master/) - [spdlog](https://gitee.com/jzhufudan/spdlog/tree/v1.8.2/) - [cpptoml](https://gitee.com/jzhufudan/cpptoml/tree/v0.1.1/) - [curlpp](https://gitee.com/jzhufudan/curlpp/tree/master/) - [args](https://gitee.com/jzhufudan/args/tree/6.2.4/) - [hdf5](https://gitee.com/jzhufudan/hdf5/tree/hdf5-1_12_0/) 1. 拉取指定版本代码 ```shell git clone https://gitee.com/jzhufudan/fmt --depth 1 --branch 7.1.3 git clone https://gitee.com/jzhufudan/googletest --depth 1 --branch release-1.10.0 git clone https://gitee.com/jzhufudan/rapidjson --depth 1 git clone https://gitee.com/jzhufudan/spdlog --depth 1 --branch v1.8.2 git clone https://gitee.com/jzhufudan/cpptoml --depth 1 --branch v0.1.1 git clone https://gitee.com/jzhufudan/curlpp --depth 1 ``` 2. 在各自文件夹下 ```shell mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX=~/install make -j && make install ``` 3. 指定编译器需要额外cmake参数如 `-DCMAKE_C_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/g++`; 或者使用 `scl enable devtoolset-9 zsh`. 4. 编译`curlpp`时指定cmake参数如 `-DCURLPP_BUILD_SHARED_LIBS=OFF`; 5. 编译 `args`: ```shell git clone https://gitee.com/jzhufudan/args --depth 1 --branch 6.2.4 cd args && make install DESTDIR=~/install ``` 6. 编译 `hdf5`, [帮助](https://gitee.com/jzhufudan/hdf5/blob/hdf5-1_12_0/release_docs/INSTALL_CMake.txt): ```shell git clone https://gitee.com/jzhufudan/hdf5 --depth 1 --branch hdf5-1_12_0 cd hdf5 && mkdir build && cd build cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_TESTING:BOOL=ON -DHDF5_BUILD_TOOLS:BOOL=ON .. cmake --build . --config Release ctest . -C Release cpack -C Release CPackConfig.cmake ```