libbson is a library providing useful routines related to building, parsing, and iterating BSON documents. It is a useful base for those wanting to write high-performance C extensions to higher level languages such as python, ruby, or perl.
Libbson tries to support a variety of operation systems and architectures. The following are known to work. If your platform is not listed here, it may still work, we simply haven't tested it. If you would like us to add your platform here, we would be happy to hear from you.
- RHEL/CentOS 5, 6, 7beta
- SLES 11 SP3
- Ubuntu 12.04 LTS
- Debian 7
- SmartOS
- Solaris
- FreeBSD 10
- Windows Vista, 7, 8
- x86
- x86_64/amd64
- SPARC
- ARM
- PowerPC
- GCC 4.1 and newer
- Clang 3.3 and newer
- Visual Studio (MSVC) 2010 and newer
- Oracle Solaris Studio (5.7 and newer, Solaris 10)
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
Builds on Windows Vista and Higher require cmake to build Visual Studio project files. Alternatively, you can use cygwin or mingw with the automake based build.
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
For the adventurous, you can cross-compile for Windows from Fedora easily using mingw.
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
You can run the unit tests with
make test
tar xzf libbson-$ver.tar.gz
./configure
make
sudo make install
You may be interested in the following options for ./configure
.
These are not availble when using the alternate CMake build system.
--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).
In your source code:
#include <bson.h>
To get the include path and libraries appropriate for your system.
gcc my_program.c $(pkg-config --cflags --libs libbson-1.0)
See the examples/
directory for how to use the libbson library in your
application.
See the doc/
directory for documentation on individual types.