libbson 是一个库,提供了与构建、解析和迭代 BSON 文档相关的实用程序。对于想要为 Python、Ruby 或 Perl 等高级语言编写高性能 C 扩展的开发者非常有用。
libbson 尝试支持多种操作系统和架构。以下是一些已知可以工作的情况。如果您的平台未在此列出,它可能仍然有效,我们只是尚未测试。如果您希望我们将您的平台添加到此处,我们将非常高兴听到您的意见。
yum install git automake autoconf libtool gcc
apt-get install git-core automake autoconf libtool gcc
pkg install git automake autoconf libtool gcc pkgconf
pkgin install git automake autoconf libtool gcc47 gmake pkg-config
export PATH=/opt/local/gcc47/bin:$PATH
Windows Vista 及以上版本的构建需要 cmake 来构建 Visual Studio 项目文件。或者,您可以使用基于 automake 的构建与 cygwin 或 mingw 一起使用。
git clone git://github.com/mongodb/libbson.git
cd libbson
cmake.exe -G "Visual Studio 10 Win64" "-DCMAKE_INSTALL_PREFIX=C:\install\path"
msbuild.exe ALL_BUILD.vcxproj
msbuild.exe INSTALL.vcxproj
对于有冒险精神的人,您可以使用 mingw 从 Fedora 容易地交叉编译 Windows 版本。
sudo yum install mingw64-gcc automake autoconf libtool
./configure --host=x86_64-w64-mingw32
git clone git://github.com/mongodb/libbson.git
cd libbson/
./autogen.sh
make
sudo make install
您可以使用以下命令运行单元测试:
make test
tar xzf libbson-$ver.tar.gz
./configure
make
sudo make install
以下是一些可能在 ./configure
中使用的选项。当使用替代的 CMake 构建系统时,这些选项不可用。
--help Show all possible help options.
There are many more than those displayed here.
--enable-optimizations Enable various compile and link optimizations.
--enable-debug Enable debugging features.
--enable-debug-symbols Link with debug symbols in tact.
--enable-hardening Enable stack protector and other hardening features.
--enable-silent-rules Force silent rules like the Linux kernel.
--enable-coverage Compile with gcov support.
--enable-static Build static archives (.a).
在您的源代码中
#include <bson.h>
以获取适合您系统的包含路径和库。
gcc my_program.c $(pkg-config --cflags --libs libbson-1.0)
请参阅 examples/
目录,了解如何在您的应用程序中使用 libbson 库。
请在 doc/
目录中查看单个类型的文档。
请使用 MongoDB C Driver JIRA 项目来报告错误或请求功能。