MongoDB系列二:安装mongoDB C/C++驱动(New C++11 driver)

夏侯瑞
2023-12-01

CentOS7.2上安装mongodb cxx驱动笔记

1.如果CMAKE版本低于3.2版本,要先升级CMAKE 到3.2版本,安装c++驱动要求升级到v3.2以上版本
删除现有版本:
yum remove cmake

wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz
tar zxvf cmake-3.2.2.tar.gz
cd cmake-3.2.2
./configure
make
make install

ln -s /usr/local/bin/cmake /usr/bin //做一个软连接
查看cmake版本:
cmake --version

2.安装MongoDB C driver
yum install pkg-config openssl-devel cyrus-sasl-devel

wget https://github.com/mongodb/mongo-c-driver/releases/download/1.6.0/mongo-c-driver-1.6.0.tar.gz
tar -xvzf mongo-c-driver-1.6.0.tar.gz
cd mongo-c-driver-1.6.0
./configure –disable-automatic-init-and-cleanup

make
sudo make install
cd ../

3.安装automake
wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz
tar -zxvf automake-1.14.tar.gz
cd automake-1.14
./bootstrap.sh
./configure
make
make install

4.安装libbson
wget https://github.com/mongodb/libbson/releases/download/1.6.0/libbson-1.6.0.tar.gz
tar -xzvf libbson-1.6.0.tar.gz
cd libbson-1.6.0/
./configure –prefix=/usr --libdir=/usr/lib64
make
make install
cd ../

5.安装mongocxx driver
wget https://github.com/mongodb/mongo-cxx-driver/archive/r3.1.1.tar.gz
tar -zxvf r3.1.1.tar.gz
cd mongo-cxx-driver/build

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_MNMLSTC=1 -DCMAKE_INSTALL_PREFIX=/usr/local ..

sudo make EP_mnmlstc_core

make && sudo make install

ln -s /usr/local/lib/libmongocxx.so /usr/lib/libmongocxx.so

安装完成。

 类似资料: