首先安装MongoDB,最简单的安装方法在终端输入:
sudo apt-get install mongodb
如果出错就:sudo apt-get update 更新下
然后启动数据库MongoDB:mongo。默认连接到test。然后就可以在Shell下简单操作Mongodb了。
============================安装pcre,scons(Mongodb辅助工具),boost库==================================
下载pcre http://sourceforge.net/projects/pcre/files/pcre/8.00/
Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86_64/b2
The following Boost libraries have portions that require a separate build
and installation step. Any library not listed here can be used by including
the headers only.
The Boost libraries requiring separate building and installation are:
- atomic
- chrono
- context
- coroutine
- date_time
- exception
- filesystem
- graph
- graph_parallel
- iostreams
- locale
- log
- math
- mpi
- program_options
- python
- random
- regex
- serialization
- signals
- system
- test
- thread
- timer
- wave
Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86_64/b2
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html
The following directory should be added to compiler include paths:
/usr/src/boost_1_54_0
The following directory should be added to linker library paths:
/usr/src/boost_1_54_0/stage/lib
再运行./b2 install 命令,默认安装在
/usr/local/lib目录下
头文件在
/usr/local/include/boost目录下
install 后面可以加参数--prefix=/usr //boost库安装完成
===============================MongoDB c++ driver======================
首先获取源代码:git clone https://github.com/mongodb/mongo-cxx-driver.git
然后切换分支:git checkout 26compat
然后用下面的命令编译:scons --prefix=/usr --use-system-boost --sharedclient --full install-mongoclient
-rw-r--r-- 1 root root 57M 5月 10 23:35 build/linux2/use-system-boost/libmongoclient.a
# ls build/linux2/use-system-boost/libmongoclient.so -alh
-rwxr-xr-x 1 root root 20M 5月 10 23:37 build/linux2/use-system-boost/libmongoclient.so
-rw-r--r-- 1 root root 57M 5月 10 23:35 /usr/lib/libmongoclient.a
-rwxr-xr-x 1 root root 20M 5月 10 23:37 /usr/lib/libmongoclient.so