chr*_*s01 2 centos centos7 cpprest-sdk
我有一个 CentOS 7(已注册 EPEL-Repo),但我在 repos 中没有找到 CPP-REST 的包(Debian 中的 libcpprest-dev)。
我需要从 vanilla 安装它还是 CentOS 中有一个软件包?
谢谢!
简短的回答...
目前(2018-10-03)没有用于 cpprestsdk(Debian 中的 libcpprest-dev)的“官方”CentOS 7 软件包。
长答案(分享这个以防它对任何人有帮助)...
您可以从源代码构建 cpprestsdk,但“如何为 Linux 构建”(https://github.com/Microsoft/cpprestsdk/wiki/How-to-build-for-Linux)的说明不包括 CentOS 或 RHEL(在撰写本文的时间,2018-10-03)。
在 CentOS 7 上构建 cpprestsdk 之前,您需要更新 boost(在撰写本文时,CentOS 7 存储库有 boost 1.53,但需要 1.54,而 1.68 是最新的)。您可以这样做来更新(以 boost 1.68 为例):
cd && wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz
tar -xzvf boost_1_68_0.tar.gz
cd ~/boost_1_68_0
./bootstrap.sh --prefix=/opt/boost
sudo ./b2 install --prefix=/opt/boost --with=all
Run Code Online (Sandbox Code Playgroud)
更新 boost 后,我能够像这样在 CentOS 7 上构建 cpprestsdk ......
安装一些需要的工具/库:
sudo yum -y install git cmake3 openssl-devel gcc-c++ make
Run Code Online (Sandbox Code Playgroud)
下载 cpprestsdk 项目:
git clone https://github.com/Microsoft/cpprestsdk.git casablanca
Run Code Online (Sandbox Code Playgroud)
cpprestsdk 希望将警告视为错误。我不得不通过在 ~/casablanca/Release/CMakeLists.txt 中注释掉这一行来关闭它:
#set(WERROR ON CACHE BOOL "Treat Warnings as Errors.")
Run Code Online (Sandbox Code Playgroud)
准备/构建 cpprestsdk 项目:
cd casablanca/Release
mkdir build.release && cd build.release
cmake3 .. -DCMAKE_BUILD_TYPE=Release -DBOOST_ROOT=/opt/boost
make
Run Code Online (Sandbox Code Playgroud)
安装头文件和库
sudo make install
Run Code Online (Sandbox Code Playgroud)
请注意,我正在调用 cmake3(而不是 cmake)并且指定了 boost 根;这与似乎是为 Ubuntu(不是 CentOS 或 RHEL)编写和测试的官方说明不同。要使用 cpprestsdk 构建我的项目,我必须使用 ldconfig 来查找库路径。