CentOS7安装mong-c-driver, mongo-cxx-driver
1.重新编译和安装 OpenSSL
openssl 依赖包:
sudo yum install perl-core perl pcre-devel zlib zlib-devel cyrus-sasl cyrus-sasl-devel libtemplate-perl
wget -c https://www.openssl.org/source/openssl-1.0.2p.tar.gz tar -xzvf openssl-1.0.2p.tar.gz cd openssl-1.0.2p/
###特别注意,要加上 -fPIC 条件!!!!
./config no-shared zlib-dynamic -fPIC make make test sudo make install
编辑 ~/.bash_profile 文件 (特别注意 ssl/bin 目录一定要添加)
PATH添加openssl的路径 /usr/local/ssl/bin
在添加其他3个路径
OPENSSL_ROOT_DIR=/usr/local/ssl
OPENSSL_CRYPTO_LIBRARY=/usr/local/ssl/lib
OPENSSL_INCLUDE_DIR=/usr/local/ssl/include
export OPENSSL_ROOT_DIR
export OPENSSL_CRYPTO_LIBRARY
export OPENSSL_INCLUDE_DIR
2.(mongo-cxx-driver编译过程) 需要安装git
sudo yum install git
3. CMake的安装
请参考我的这篇文章
https://www.cnblogs.com/music-liang/p/12900511.html
3.CentOS7安装 mongo-c-driver
下载最新版本驱动 ,这里是 1.16.2
下载地址:
https://github.com/mongodb/mongo-c-driver/releases
官方参考链接:
http://mongoc.org/libmongoc/current/installing.html
安装libbson.rpm
添加mockbuild 用户
sudo useradd -s /sbin/nologin mockbuild
rpm -ivh libbson-1.3.5-6.el7.src.rpm
编译步骤:
解压文件,进入目录,创新新的目录,进入新的目录下面:
tar -zxvf mongo-c-driver-1.16.2.tar.gz cd mongo-c-driver-1.16.2 mkdir cmake-build cd cmake-build
执行下面的编译命令:
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DCMAKE_BUILD_TYPE=Release .. sudo make sudo make install
4.CentOS7安装mongo-cxx-driver
下载最新版本:这里是下载的 V3.5.0
下载地址:
https://github.com/mongodb/mongo-cxx-driver/releases
官方文档:
http://mongocxx.org/mongocxx-v3/installation/
编译步骤:
解压压缩文件,进入 mongo-cxx-driver-r3.5.0/build 目录(再次强调,要在解压出来的build目录下运行下面的命令)
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr/local/include/libmongoc-1.0 -DCMAKE_INSTALL_PREFIX=/opt/mongo-cxx-driver sudo make sudo make install