mongodb 的 C++驱动安装过程以及注意问题
来源:互联网 发布:趣店入职配mac 编辑:程序博客网 时间:2024/06/02 23:00
1。安装C++版驱动之前,先安装C版的驱动,过程如下:
我的安装平台:ubuntu14.04 64位,其他平台可参考:http://api.mongodb.org/c/current/installing.html#installing-unix(1) 安装PDK:
点击(此处)折叠或打开
- sudo apt-get install pkg-config libssl-dev libsasl2-dev
点击(此处)折叠或打开
- $ wget https://github.com/mongodb/mongo-c-driver/releases/download/1.3.0/mongo-c-driver-1.3.0.tar.gz
- $ tar xzf mongo-c-driver-1.3.0.tar.gz
- $ cd mongo-c-driver-1.3.0
- $ ./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
点击(此处)折叠或打开
- $ make
- $ sudo make install
2。C++版的安装过程:
安装前需求: 系统:Linux 或 OSX 编译器:clang++ 3.4+ 或g++ 4.9+ Cmake:CMake 3.1+(1)安装新版的Cmake:
卸载旧版本:
点击(此处)折叠或打开
- sudo apt-get remove cmake
解压安装:
点击(此处)折叠或打开
- tar -zxvf cmake-3.4.1.tar.gz
- cd cmake-3
- ./bootstrap && make && make install
点击(此处)折叠或打开
- git clone -b master https://github.com/mongodb/mongo-cxx-driver
- cd mongo-cxx-driver/build
- cmake -DCMAKE_BUILD_TYPE=Release-DCMAKE_INSTALL_PREFIX=/usr/local PKG_CONFIG_PATH=CDRIVER_INSTALL_PATH/lib/pkgconfig..
- sudo make && sudo make install
3。解决问题
在测试C驱动的时候,编译链接生成可执行文件,例子是/mongo-c-driver-1.3.0/examples下面的example-client.c
执行如下命令:
点击(此处)折叠或打开
- gcc example-client.c-o example $(pkg-config--cflags --libs libmongoc-1.0)
点击(此处)折叠或打开
- ./example
- ./example: errorwhile loading shared libraries: libmongoc-1.0.so.0: cannot open shared object file: No such file or directory
点击(此处)折叠或打开
- ldd example
- linux-vdso.so.1=> (0x00007fffd09ca000)
- libmongoc-1.0.so.0=> not found
- libbson-1.0.so.0=> not found
- libc.so.6=> /lib/x86_64-linux-gnu/libc.so.6(0x00007f9c1a0c5000)
- /lib64/ld-linux-x86-64.so.2(0x00007f9c1a48a000)
测试解决办法,成功运行:
点击(此处)折叠或打开
- LD_LIBRARY_PATH=/usr/local/lib./example
点击(此处)折叠或打开
- cat ld.so.conf
- include /etc/ld.so.conf.d/*.conf
- cd /etc/ld.so.conf.d/
- fakeroot-x86_64-linux-gnu.conf x86_64-linux-gnu_EGL.conf
i686-linux-gnu.conf x86_64-linux-gnu_GL.conf
libc.conf zz_i386-biarch-compat.conf
x86_64-linux-gnu.conf
点击(此处)折叠或打开
- cd /usr/local/lib/
- ls
- libbson-1.0.la libmongoc-1.0.la libmongocxx.a
- libbson-1.0.so libmongoc-1.0.so libmongocxx.so
- libbson-1.0.so.0 libmongoc-1.0.so.0 libmongocxx.so.0
- libbson-1.0.so.0.0.0 libmongoc-1.0.so.0.0.0 libmongocxx.so.0.3.0
- libbsoncxx.a libmongoc-priv.la pkgconfig
- libbsoncxx.so libmongoc-priv.so python2.7
- libbsoncxx.so.0 libmongoc-priv.so.0 python3.4
- libbsoncxx.so.0.3.0 libmongoc-priv.so.0.0.0 site_ruby
- cd /etc/ld.so.conf.d/
- sudo vi mongoc.conf
参考链接:
pkg-config 用法:http://www.cppblog.com/colorful/archive/2012/05/05/173750.html
mongoC++安装指导:https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver)
mongoC安装指导:http://api.mongodb.org/c/current/?_ga=1.224779610.177216698.1449303645
C 驱动使用实例:http://api.mongodb.org/c/current/tutorial.html#starting-mongod
0 0
- mongodb 的 C++驱动安装过程以及注意问题
- MongoDB-C驱动的安装
- mongodb安装注意问题
- 安装MongoDB的方法以及安装过程中遇到的问题
- MongoDB的安装以及自启动问题
- jbpm安装过程注意问题
- 四通oki打印机驱动安装注意的问题
- Libnids安装过程以及存在的问题
- 安装cuda过程以及遇到的问题
- mongodb的c驱动使用
- 总结Android调用C的编程过程注意问题
- Genymotion安装教程以及一些需要注意的问题
- 编译安装mpeg4ip过程中需要注意的问题
- 安装redis过程中需要注意的问题
- OpenGL安装过程中注意的几点问题
- scala安装过程中需要注意的问题
- MongoDB的安装以及使用说明
- cocoaPods 安装以及安装过程中出现的问题
- python模拟登录微博网站利用urllib2 和 cookie
- 开启MongoDB不能访问web控制台问题;; access MongoDB over HTTP
- mongodb 建库过程(ubuntu shell 版)
- C#中的Dictionary字典类介绍
- mongodb C/C++ driver 通过帐号验证登录mongo服务器并进行相应操作
- mongodb 的 C++驱动安装过程以及注意问题
- 关闭 mongodb 出错: Error: shutdown failed: not authorized
- 局部敏感哈希(Locality-Sensitive Hashing, LSH)方法介绍
- 'Building workspace' has encountered a problem.Errors occurred during the build.
- NYOJ1016(德莱联盟)(判断线段相交)
- Navicat 错误代码ORA-28547
- Quartz定时任务简单实现
- 某公司面试题
- 匈牙利命名表