Installing the MongoDB C Driver

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

Supported Platforms

The MongoDB C Driver 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 driver 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


Building on Unix


OpenSSL is required for authentication or for SSL connections to MongoDB. Kerberos or LDAP support requires Cyrus SASL.

To install all optional dependencies on RedHat / Fedora:

$ sudo yum install pkg-config openssl-devel cyrus-sasl-devel

On Debian / Ubuntu:

$ sudo apt-get install pkg-config libssl-dev libsasl2-dev

On FreeBSD:

$ su -c 'pkg install pkgconf openssl cyrus-sasl2'

Building from a release tarball

Unless you intend on contributing to the mongo-c-driver, you will want to build from a release tarball.

The most recent release of libmongoc is 1.3.4 and can be downloaded here. The following snippet will download and extract the driver, and configure it:

$ wget
$ tar xzf mongo-c-driver-1.3.4.tar.gz
$ cd mongo-c-driver-1.3.4
$ ./configure

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

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

Generate man pages                               : no
Install man pages                                : no

mongo-c-driver contains a copy of libbson, in case your system does not already have libbson installed. The configure script will detect if libbson is not installed and use the bundled libbson.

$ make
$ sudo make install

Building from git

To build an unreleased version of the driver 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


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

Once you have the dependencies installed, clone the repository and build the current master or a particular release tag:

$ git clone
$ cd mongo-c-driver
$ git checkout x.y.z  # To build a particular release
$ ./ --with-libbson=bundled
$ make
$ sudo make install

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 xcode-select --install in the Terminal and follow the instructions.

OpenSSL support on El Capitan

Beginning in OS X 10.11 El Capitan, OS X no longer includes the OpenSSL headers. To build the driver with SSL on El Capitan and later, first install Homebrew according to its instructions, then:

$ brew install openssl
$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"

Building on OS X

Download the latest release tarball:

$ curl -LO
$ tar xzf mongo-c-driver-1.3.4.tar.gz
$ cd mongo-c-driver-1.3.4

Build and install the driver:

$ ./configure
$ make
$ sudo make install

Generating the documentation on OS X

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

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

Installing on Mac OS X

To build the C Driver on a Mac, install the prerequisites in order to build it from source. It is recommended to use Homebrew:

$ brew install git automake autoconf libtool pkgconfig

Additionally, XCode is required. The driver can then be installed by following the directions for building from source.

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, a dependency of the C driver. The following assumes we are compiling for 64-bit Windows using Visual Studio 2010 Express which can be freely downloaded from Microsoft.

cd mongo-c-driver-1.3.4\src\libbson
cmake -G "Visual Studio 10 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver"

(Run cmake -LH . for a list of other options.)

Now that we have project files generated, we can either open the project in Visual Studio or compile from the command line. Let's build using the command line program msbuild.exe

msbuild.exe ALL_BUILD.vcxproj

Now that libbson is compiled, let's install it using msbuild. It will be installed to the path specified by CMAKE_INSTALL_PREFIX.

msbuild.exe INSTALL.vcxproj

You should now see libbson installed in C:\mongo-c-driver

Now let's do the same for the MongoDB C driver.

cd mongo-c-driver-1.3.4
cmake -G "Visual Studio 2010 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" "-DBSON_ROOT_DIR=C:\mongo-c-driver"
msbuild.exe ALL_BUILD.vcxproj
msbuild.exe INSTALL.vcxproj

All of the MongoDB C Driver's components will now be found in C:\mongo-c-driver.