C Client Library

Couchbase Server for C Development

The C library provides fast access to documents in Couchbase Server 2.0. With JSON documents and Couchbase server 2.0 you have new ways to index and query data stored in the cluster through views. This client library, libcouchbase, also simplifies requests to Views through its handling of HTTP transport.

This Couchbase Client Library for C and C++ provides a complete interface to the functionality of Couchbase Server. For more on writing C programs with Couchbase Server Getting Started guide.

Step 0: Get a Server

Get & Install Couchbase Server. Come back here when you're done.

Step 1: Get a Client Library


Install either with the package commands for your operating system or by adding the Couchbase repository to your operating system's package manager.

Enterprise Linux (CentOS, Red Hat)

Find the right row for your distribution and architecture, and copy/paste the command in your shell

Version Architecture Command
5.x 32-Bit
shell> sudo wget -O /etc/yum.repos.d/couchbase.repo http://packages.couchbase.com/rpm/couchbase-centos55-i386.repo
5.x 64-Bit
shell> sudo wget -O /etc/yum.repos.d/couchbase.repo http://packages.couchbase.com/rpm/couchbase-centos55-x86_64.repo
6.x 32-Bit
shell> sudo wget -O /etc/yum.repos.d/couchbase.repo http://packages.couchbase.com/rpm/couchbase-centos62-i686.repo
6.x 64-Bit
shell> sudo wget -O /etc/yum.repos.d/couchbase.repo http://packages.couchbase.com/rpm/couchbase-centos62-x86_64.repo

Once done, execute the following (for all platforms)

shell> sudo yum check-update
shell> sudo yum install -y  libcouchbase2-libevent libcouchbase-devel


Release Command
Lucid (10.04)
sudo wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1004.list
Precise (12.04)
sudo wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1204.list
Trusty (14.04)
sudo wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1404.list

Once done, do the following:

# Install GPG key
shell> wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add - 
shell> sudo apt-get update
shell> sudo apt-get install libcouchbase2-libevent libcouchbase-dev

Mac OS X

This client library is available via a homebrew recipe.  After installing homebrew, to install libcouchbase:

shell> brew install libcouchbase

Note: if you have upgraded to Mountain Lion after having installed homebrew previously, The Hitchhiker's Guide to Riding A Mountain Lion is a good guide to resolving any problems.


Archives for Windows are included. Bundled in the archive are the header files (inside include), the dynamic library (bin/libcouchbase.dll), the import library (lib/libcouchbase.lib) and the debug variants (bin/libcouchbase_d.dll and lib/libcouchbase_d.lib). The cbc utility is included as well.

If you wish to link against libcouchbase from a Windows application, you must select the archive appropriate for the version of Visual Studio being used to compile your application.

Compiler Architecture File
9 (VS 2008) x64 libcouchbase-2.4.1_amd64_vc9.zip
9 (VS 2008) x86 libcouchbase-2.4.1_x86_vc9.zip
10 (VS 2010) x64 libcouchbase-2.4.1_amd64_vc10.zip
10 (VS 2010) x86 libcouchbase-2.4.1_x86_vc10.zip
11 (VS 2012) x64 libcouchbase-2.4.1_amd64_vc11.zip
11 (VS 2012) x86 libcouchbase-2.4.1_x86_vc11.zip.

Source Archives

If neither from listed above ways to install libcouchbase doesn't fit your needs, you can install it from the source tarball: libcouchbase-2.4.1.tar.gz

If you are using unix-like operation system, this typical spell will install it for you. It only depends on development headers either libevent or libev.

shell> ./configure && make && sudo make install

On MS Windows systems, you can use CMake to generate a project for Visual Studio, for example:

shell> cmake -G "Visual Studio 10"

Standalone Binary Packages

If you don't want to install from a repository, you may find standalone binary packages at the package archive. Select the tar archive appropriate for your distribution and extract it. The extracted contents contain the binary packages (e.g. deb or rpm) that you can manually install via your package manager.

Step 2: Try it out!

You can see a minimal example in the library's API documentation