MongoDB C++ 开发环境搭建
来源:互联网 发布:怎么修改淘宝收获地址 编辑:程序博客网 时间:2024/05/20 07:52
编译使用C++ MongoDB Driver
本博客在linux下编译使用C++ MongoDB Driver
准备工作
- GCC 4.8.2+
- CMake 3.2+
- The MongoDB C driver version 1.3.5+
- boost 1.56+
编译安装MongoDB C Driver
The C++ driver uses libbson and the MongoDB C driver internally.
安装c++driver前需要先安装libbson 和 c driver:
$ sudo apt-get install pkg-config libssl-dev libsasl2-dev
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.3.5/mongo-c-driver-1.3.5.tar.gz
$ tar xzf mongo-c-driver-1.3.5.tar.gz
$cd mongo-c-driver-1.3.5/
$ ./configure
如果都配置正确的话机会看到:
libmongoc was configured with the following options:
Build configuration:
Enable debugging (slow) : no
Compile with debug symbols (slow) : no
Enable GCC build optimization : yes
Enable automatic binary hardening : yes
Code coverage support : no
Cross Compiling : no
Fast counters : no
SASL : sasl2
SSL : yes
Libbson : bundled
Documentation:
Generate man pages : no
Install man pages : no
mongo-c-driver 已经包含了 libbson , make 安装:
$ make
$ sudo make install
编译安装 MongoDB C++ driver
$git clone -b master https://github.com/mongodb/mongo-cxx-driver
$git checkout r3.0.0
$cd build/
$cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
$sudo make ; //注意这里要加上sudo权限 因为上一条命令加上了 /usr/local
$sudo make install
添加环境变量
vim ~/.bashrc
export LD_LIBRARY_PATH=/usr/lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH //添加这个环境变量,不然pkg-config找不到库的路径
编写实例代码,参考后续博客
参考:
https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver)
- MongoDB C++开发环境搭建
- mongoDb c++ 开发环境搭建
- MongoDB C++ 开发环境搭建
- MongoDB C++开发环境搭建
- MongoDB C++开发环境搭建linux平台
- 全方位的NodeJS+mongodb开发环境搭建
- Ubuntu + Node.js + Mongodb开发环境搭建
- mongodb学习(搭建开发环境+简单入门)
- spring+springmvc+mongodb开发环境搭建
- php+mongodb开发环境搭建(linux+apache+mongodb+php)
- ubuntu C开发环境搭建
- Eclipse+C开发环境搭建
- C语言开发环境搭建
- C语言开发环境搭建
- Objective C开发工具搭建开发环境。
- mongodb环境搭建
- Mongodb 环境搭建
- mongodb的环境搭建
- unity实现自己的一个消息系统
- spring容器与管理bean的生命周期
- Smarty
- 345. Reverse Vowels of a String
- 单例的三种实现及理解
- MongoDB C++ 开发环境搭建
- ubuntu 配置shadowsocks
- oracle 创建数据库 在新创建的数据库中创建用户 删除创建数据库 链接orcl
- Android JNI知识简介
- 【UOJ #209】【UER #6】票数统计
- 《Linux内核设计与实现》笔记——VFS
- python中通过模块名引用子模块机制
- epoll如何判断客户端不可读
- Ajax前台返回JSON数据后再Controller中直接转换成类型使用,后台接收json转成实体的方法