Installing Libbson

The following guide will step you through the process of downloading, building, and installing the current release of libbson.

Supported Platforms

Libbson is continuously tested on GNU/Linux, Windows 7, Mac OS X 10.10, and Solaris 11 (Intel and Sparc). GCC, Clang, and Visual Studio 2013 compilers are continuously tested.

The library supports the following operating systems and CPU architectures:

Operating Systems

CPU Architectures

Compiler Toolchain

  • GNU/Linux

  • Solaris 11

  • Mac OS X 10.6 and newer

  • Windows Vista, 7, and 8

  • FreeBSD

  • x86 and x86_64

  • ARM

  • PPC

  • SPARC

Building on Unix

Building from a release tarball

Unless you intend on contributing to libbson, you will want to build from a release tarball.

The most recent release of libbson is 1.2.1 and can be downloaded here. The following snippet will download and extract the code, and configure it:

$ wget https://github.com/mongodb/libbson/releases/download/1.2.1/libbson-1.2.1.tar.gz
$ tar xzf libbson-1.2.1.tar.gz
$ cd libbson-1.2.1
$ ./configure

If configure completed successfully, you'll see something like the following describing your build configuration.

libbson was configured with the following options:

        Build configuration:
        Enable debugging (slow)                          : no
        Enable extra alignment (required for 1.0 ABI)    : yes
        Compile with debug symbols (slow)                : no
        Enable GCC build optimization                    : yes
        Enable automatic binary hardening                : yes
        Code coverage support                            : no
        Cross Compiling                                  : no
        Big endian                                       : no
        Link Time Optimization (experimental)            : no

        Documentation:
        man                                              : no
        HTML                                             : no

Build and install:

$ make
$ sudo make install

Building from git

To build an unreleased version of the library from git requires additional dependencies.

RedHat / Fedora:

$ sudo yum install git gcc automake autoconf libtool

Debian / Ubuntu:

$ sudo apt-get install git gcc automake autoconf libtool

FreeBSD:

$ su -c 'pkg install git gcc automake autoconf libtool'

Generating the documentation

Install the yelp-tools and yelp-xsl packages, then:

$ ./configure --enable-html-docs --enable-man-pages
$ make man html

Building on Mac OS X

XCode Command Line Tools

To install the XCode Command Line Tools, just type gcc in the Terminal and follow the instructions.

Building on OS X

Download the latest release tarball:

$ curl -LO https://github.com/mongodb/libbson/releases/download/1.2.1/libbson-1.2.1.tar.gz
$ tar xzf libbson-1.2.1.tar.gz
$ cd libbson-1.2.1

Build and install the library:

$ ./configure
$ make
$ sudo make install

Generating the documentation on OS X

Homebrew is required to generate libbson's HTML documentation and man pages:

$ brew install yelp-xsl yelp-tools
$ ./configure --enable-html-docs --enable-man-pages
$ make man html

Building on Windows

Building on Windows requires Windows Vista or newer and Visual Studio 2010 or newer. Additionally, cmake is required to generate Visual Studio project files.

Let's start by generating Visual Studio project files for libbson. The following assumes we are compiling for 64-bit Windows using Visual Studio 2010 Express which can be freely downloaded from Microsoft.

> cd libbson-1.2.1
> cmake -G "Visual Studio 2010 Win64" "-DCMAKE_INSTALL_PREFIX=C:\libbson"
> msbuild.exe ALL_BUILD.vcxproj
> msbuild.exe INSTALL.vcxproj

You should now see libbson installed in C:\libbson