Lcb_version_g variable not being set?



Is there an issue with this code or with the C library? Can’t think of a reason why the second printf doesn’t spit the version out. Does this work differently on another platform?

#include <stdio.h>
#include <libcouchbase/couchbase.h>

int main(int argc, char **argv)
printf(“lcb_get_version = %s\n”, lcb_get_version(NULL));
printf(“lcb_version_g = %u\n”, lcb_version_g );

return 0;


And the output:
$ ./a.out
lcb_get_version = 2.6.1
lcb_version_g = 0

Link to lcb_version_g definition in the online documentation:



The formatting killed my includes:

include < stdio.h >

include < libcouchbase/couchbase.h >


What OS are you using, and how are you linking against the library?

#include <libcouchbase/couchbase.h>
#include <stdio.h>

int main(int argc, char **argv)
    printf("lcb_version_g=%lu\n", lcb_version_g);
    return 0;


Sorry, forgot to include the obvious. It’s on OS X 10.11.5.

$ gcc -o testVersion testVersion.c -lcouchbase

This is not the libcouchbase from homebrew but a locally compiled version from the libcouchbase-2.6.1.tar.gz package.

$ cbc version
Runtime: Version=2.6.1, Changeset=0xdeadbeef
Headers: Version=2.6.1, Changeset=0xdeadbeef
IO: Default=libevent, Current=libevent


Are you sure you’re using one compiled from the downloaded tarball, or is this one you obtained from GitHub? The build scripts rely that the tarball used is either one generated from make dist (from a Git repository) or from the git repository tree itself. Internal scripts use git describe to derive the current version information (based on Git tags)