Installation and API Reference

Installation and API Reference

You can install the C SDK from a repository for your platform, download prebuilt binaries or compile from source.

The latest API reference can be found at http://docs.couchbase.com/sdk-api/couchbase-c-client-2.6.0/. The API documentation is generated from the source package using the Doxygen utility. See the source README for instructions on how to generate the documentation locally.

Installing from repositories (Linux)

If you are using a Debian or Redhat based Linux distribution, you may install from one of the Couchbase package repositories. You can set up the Couchbase repositories by using the couchbase-release package for your distribution. You will typically want to install the development files (which will also install the core library) and the command line utilities.

Debian/Ubuntu
# Only needed during first-time setup:
http://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-2-amd64.deb
sudo dpkg -i couchbase-release-1.0-2-amd64.deb
# Will install or upgrade packages
sudo apt-get update
sudo apt-get install libcouchbase-dev libcouchbase2-bin build-essential
CentOS/RHEL
# Only needed during first-time setup:
wget http://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-0-x86_64.rpm
sudo rpm -ivh couchbase-release-1.0-0-x86_64.rpm
# Will install or upgrade existing packages
sudo yum install libcouchbase-devel libcouchbase2-bin gcc gcc-c++
Note: Debian Jessie (8.0) and Ubuntu Xenial (16.04) support were added in the 1.0-2 version of couchbase-release.

Linux advanced installation

If you want to install the C SDK manually, either from a static binary package or by manually configuring the repositories, you can use the following procedures.

Common Binary Packages

The various Linux distributions contain the following packages:
  • libcouchbase2-core: The core library package
  • libcouchbase-dev (or libcouchbase-devel): The development package, required if building SDKs which depend on the C SDK
  • libcouchbase2-bin: The command line utilities (cbc and cbc-pillowfight)
  • libcouchbase2-libevent: Optional but recommended component for I/O performance. Can also be used to integrate with libevent (see Using external event loops).
  • libcouchbase2-libev: Optional, for use with applications that make use of event loop integration with libev (see Using external event loops).

Configuring yum repositories (CentOS, Redhat Enteprise Linux)

This section assumes you know how to add an external yum repository and Linux quick start explains the steps it will perform on your distribution. To configure the repository:
  1. Find the appropriate repository location for your distribution in the following table. CentOS and RHEL allow 32-bit packages to be installed on a 64-bit system. This is usually not what you want, so ensure that you use the 64-bit repository for your 64-bit system (unless you specifically want the 32-bit SDK).
    Version Architecture Repository
    6 32-bit http://packages.couchbase.com/rpm/6.2/i686
    6 64-bit http://packages.couchbase.com/rpm/6.2/x86_64
    7 64-bit http://packages.couchbase.com/rpm/7/x86_64
  2. Create a couchbase.repo file in your /etc/yum.repos.d directory. It should look similar to the following:
    [couchbase]
    enabled = 1
    name = Couchbase package repository
    baseurl = REPLACE THIS WITH THE ACTUAL REPOSITORY FOR YOUR PLATFORM
    gpgcheck = 1
    gpgkey = http://packages.couchbase.com/rpm/couchbase-rpm.key 

Configuring APT repositories (Debian, Ubuntu)

This section assumes some knowledge of Apt and Linux quick start explains the steps it will perform on your distribution. To configure the repository:

  1. Download the Couchbase GPG key from http://packages.couchbase.com/ubuntu/couchbase.key.
  2. Add the key to the list of trusted package keys. Use the apt-key add command. For example, apt-key add couchbase.key.
  3. Create a couchbase.list file in /etc/apt/sources.list.d. The file should contain the repository for your distribution. Repositories are available for the following distributions:
    Distribution Repository Entry
    Precise (Ubuntu 12.04) deb http://packages.couchbase.com/ubuntu precise precise/main
    Trusty (Ubuntu 14.04) deb http://packages.couchbase.com/ubuntu trusty trusty/main
    Debian Wheezy (Stable) deb http://packages.couchbase.com/ubuntu wheezy wheezy/main

Installing on Mac OS X with Homebrew

The C SDK can be installed on Mac OS X via Homebrew:

$ brew update # Needed if upgrading to a newer version
$ brew install libcouchbase 

Installing binary packages without a repository

You can install standalone packages by downloading a TAR archive containing the necessary binary packages for your platform.

Installing RPM packages manually

$ tar xf libcouchbase-2.4.0_centos62_x86_64.tar
$ cd libcouchbase-2.4.0_centos62_x86_64/
$ sudo rpm -ivh libcouchbase-devel-2.4.0-1.el6.x86_64.rpm libcouchbase2-core-2.4.0-1.el6.x86_64.rpm \
libcouchbase2-bin-2.4.0-1.el6.x86_64.rpm libcouchbase2-libevent-2.4.0-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:libcouchbase2-core     ########################################### [ 25%]
   2:libcouchbase-devel     ########################################### [ 50%]
   3:libcouchbase2-bin      ########################################### [ 75%]
   4:libcouchbase2-libevent ########################################### [100%]

Installing Debian packages manually

$ tar xf libcouchbase-2.2.0_ubuntu1204_amd64.tar
$ cd libcouchbase-2.2.0_ubuntu1204_amd64
$ sudo dpkg -i libcouchbase2-core_2.2.0-2453_amd64.deb libcouchbase2-libevent_2.2.0-2453_amd64.deb \
libcouchbase-dev_2.2.0-2453_amd64.deb libcouchbase2-bin_2.2.0-2453_amd64.deb
Selecting previously unselected package libcouchbase2-core.
(Reading database ... 28297 files and directories currently installed.)
Unpacking libcouchbase2-core (from libcouchbase2-core_2.2.0-2453_amd64.deb) ...
Selecting previously unselected package libcouchbase2-libevent.
Unpacking libcouchbase2-libevent (from libcouchbase2-libevent_2.2.0-2453_amd64.deb) ...
Selecting previously unselected package libcouchbase-dev.
Unpacking libcouchbase-dev (from libcouchbase-dev_2.2.0-2453_amd64.deb) ...
Selecting previously unselected package libcouchbase2-bin.
Unpacking libcouchbase2-bin (from libcouchbase2-bin_2.2.0-2453_amd64.deb) ...
Setting up libcouchbase2-core (2.2.0-2453) ...
Processing triggers for man-db ...
Setting up libcouchbase2-bin (2.2.0-2453) ...
Setting up libcouchbase2-libevent (2.2.0-2453) ...
Setting up libcouchbase-dev (2.2.0-2453) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Installing from source

Download the source archives: Downloads .You should first extract the library, configure it, and then install it. For example:
$ tar xf libcouchbase-2.4.0.tar.gz
				$ cd libcouchbase-2.4.0
				$ ./configure.pl
				$ sudo make install

Windows binary packages

Windows binary packages can be found in Downloads. Included are the header files, release and debug variants of the DLLs and import libraries, and release and debug variants of the command line tools.

Be sure to select the proper package for the compiler and architecture your application is using.

Note:

If there are no binaries available for your visual studio version, then using a binary from any other visual studio version is likely to work. Most of the issues related to mixing Visual Studio binary versions involve changing and incompatible C++ APIs or incompatible C Runtime (CRT) objects and functions. Since the Couchbase C SDK does not expose a C++ API, and since it does not directly expose any CRT functionality, it should be safe for use so long as your application can link to the library at compile-time. The windows runtime linker will ensure that each binary is using the appropriate version of the Visual C Runtime (MSVCRT.DLL).