Error when installing Couchbase PHP client

Hi all,
I’m using SUSE Linux Enterprise Server 11.3 (x86_64) and PHP 5.6.28
I’m getting this error when install couchbase-2.2.x (couchbase-2.1.0 works fine):

/usr/local/zend/bin/pecl install --alldeps couchbase
downloading couchbase-2.2.4.tgz ...
....
....
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/pear/temp/couchbase -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootkGbrQJ/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootkGbrQJ/couchbase-2.2.4/main -I/tmp/pear/temp/couchbase -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/couchbase/couchbase.c  -fPIC -DPIC -o .libs/couchbase.o
/tmp/pear/temp/couchbase/couchbase.c:97:29: warning: extra tokens at end of #ifdef directive
/tmp/pear/temp/couchbase/couchbase.c: In function ‘zm_startup_couchbase’:
/tmp/pear/temp/couchbase/couchbase.c:155: error: ‘LCB_N1XSPEC_T_DEFAULT’ undeclared (first use in this function)
/tmp/pear/temp/couchbase/couchbase.c:155: error: (Each undeclared identifier is reported only once
/tmp/pear/temp/couchbase/couchbase.c:155: error: for each function it appears in.)
/tmp/pear/temp/couchbase/couchbase.c:156: error: ‘LCB_N1XSPEC_T_GSI’ undeclared (first use in this function)
/tmp/pear/temp/couchbase/couchbase.c:157: error: ‘LCB_N1XSPEC_T_VIEW’ undeclared (first use in this function)
make: *** [couchbase.lo] Error 1
ERROR: `make' failed

Please help.
Thank you!
Carlos

What compiler do you use?

gcc version 4.3.4
GNU Make 3.81
PEAR Version: 1.10.1
PHP Version: 5.6.28
Zend Engine Version: 2.6.0
Running on: Linux 3.0.76-0.11-default #1 SMP Fri Jun 14 08:21:43 UTC 2013 (ccab990) x86_64

Thank you!
Carlos

It seems like your compiler does not like my suspicious macro check (it will be fixed in next release), so what you can do now is try try this patch

mkdir /tmp/couchbase
cd /tmp/couchbase
pecl download couchbase
tar zxf couchbase-2.2.4.tgz
wget https://gist.githubusercontent.com/avsej/eb1a626b73280a95a82c26e546c3e602/raw/17deab7fb832ddfeebd7f9dd75056395ab8e7129/fix-macro-couchbase-2.2.4.patch
patch -p0 < fix-macro-couchbase-2.2.4.patch
pecl build

And if it fixes your issue, you can rebuild the package and install it locally.

sed -i s/32ecd673af084ec840289ac5a00b98cd/$(md5sum couchbase-2.2.4/couchbase.c | cut -d' ' -f1)/ package.xml
sed -i s/32ecd673af084ec840289ac5a00b98cd/$(md5sum couchbase-2.2.4/couchbase.c | cut -d' ' -f1)/ package2.xml
tar zcvf couchbase-2.2.4p1.tgz couchbase-2.2.4 package*.xml
sudo pecl install couchbase-2.2.4p1.tgz

Hi!

We continue with this error:

# mkdir /tmp/couchbase
# cd /tmp/couchbase
# /usr/local/zend/bin/pecl download couchbase
downloading couchbase-2.2.4.tgz ...
Starting to download couchbase-2.2.4.tgz (69,874 bytes)
.................done: 69,874 bytes
File /tmp/couchbase/couchbase-2.2.4.tgz downloaded
# tar zxf couchbase-2.2.4.tgz
# wget --no-check-certificate https://gist.githubusercontent.com/avsej/eb1a626b73280a95a82c26e546c3e602/raw/17deab7fb832ddfeebd7f9dd75056395ab8e7129/fix-macro-couchbase-2.2.4.patch
--2017-02-02 10:21:48--  https://gist.githubusercontent.com/avsej/eb1a626b73280a95a82c26e546c3e602/raw/17deab7fb832ddfeebd7f9dd75056395ab8e7129/fix-macro-couchbase-2.2.4.patch
Resolving gist.githubusercontent.com... 151.101.120.133
Connecting to gist.githubusercontent.com|151.101.120.133|:443... connected.
WARNING: certificate common name `www.github.com' doesn't match requested host name `gist.githubusercontent.com'.
HTTP request sent, awaiting response... 200 OK
Length: 452 [text/plain]
Saving to: `fix-macro-couchbase-2.2.4.patch'

100%[=====================================================================================================================================================>] 452         --.-K/s   in 0s      

2017-02-02 10:21:48 (8.94 MB/s) - `fix-macro-couchbase-2.2.4.patch' saved [452/452]

# patch -p0 < fix-macro-couchbase-2.2.4.patch
patching file couchbase-2.2.4/couchbase.c
# /usr/local/zend/bin/pecl build
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
building in /tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4
running: /tmp/couchbase/couchbase-2.2.4/configure --with-php-config=/usr/local/zend/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local/zend
checking for PHP includes... -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/zend/lib/php_extensions
checking for PHP installed headers prefix... /usr/local/zend/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.13.5 (ok)
checking for gawk... gawk
checking whether to enable Couchbase support... yes, shared
checking wheter to use system FastLZ bibrary... no
checking for libcouchbase in default path... found in /usr/local
checking if the PCS extension is installed... yes
checking for ld used by cc... /usr/x86_64-suse-linux/bin/ld
checking if the linker (/usr/x86_64-suse-linux/bin/ld) is GNU ld... yes
checking for /usr/x86_64-suse-linux/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/x86_64-suse-linux/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/couchbase/couchbase-2.2.4 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/main -I/tmp/couchbase/couchbase-2.2.4 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /tmp/couchbase/couchbase-2.2.4/bucket.c -o bucket.lo
mkdir .libs
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/couchbase/couchbase-2.2.4 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/main -I/tmp/couchbase/couchbase-2.2.4 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/couchbase/couchbase-2.2.4/bucket.c  -fPIC -DPIC -o .libs/bucket.o
/bin/sh /tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/couchbase/couchbase-2.2.4 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/main -I/tmp/couchbase/couchbase-2.2.4 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /tmp/couchbase/couchbase-2.2.4/cas.c -o cas.lo
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/couchbase/couchbase-2.2.4 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/main -I/tmp/couchbase/couchbase-2.2.4 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/couchbase/couchbase-2.2.4/cas.c  -fPIC -DPIC -o .libs/cas.o
/bin/sh /tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/couchbase/couchbase-2.2.4 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/main -I/tmp/couchbase/couchbase-2.2.4 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /tmp/couchbase/couchbase-2.2.4/cluster.c -o cluster.lo
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/couchbase/couchbase-2.2.4 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/main -I/tmp/couchbase/couchbase-2.2.4 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/couchbase/couchbase-2.2.4/cluster.c  -fPIC -DPIC -o .libs/cluster.o
/bin/sh /tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/couchbase/couchbase-2.2.4 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/main -I/tmp/couchbase/couchbase-2.2.4 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /tmp/couchbase/couchbase-2.2.4/couchbase.c -o couchbase.lo
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/couchbase/couchbase-2.2.4 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/include -I/tmp/pear/temp/pear-build-rootOh8s3j/couchbase-2.2.4/main -I/tmp/couchbase/couchbase-2.2.4 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/couchbase/couchbase-2.2.4/couchbase.c  -fPIC -DPIC -o .libs/couchbase.o
/tmp/couchbase/couchbase-2.2.4/couchbase.c: In function ‘zm_startup_couchbase’:
/tmp/couchbase/couchbase-2.2.4/couchbase.c:155: error: ‘LCB_N1XSPEC_T_DEFAULT’ undeclared (first use in this function)
/tmp/couchbase/couchbase-2.2.4/couchbase.c:155: error: (Each undeclared identifier is reported only once
/tmp/couchbase/couchbase-2.2.4/couchbase.c:155: error: for each function it appears in.)
/tmp/couchbase/couchbase-2.2.4/couchbase.c:156: error: ‘LCB_N1XSPEC_T_GSI’ undeclared (first use in this function)
/tmp/couchbase/couchbase-2.2.4/couchbase.c:157: error: ‘LCB_N1XSPEC_T_VIEW’ undeclared (first use in this function)
make: *** [couchbase.lo] Error 1
`make' failed

Thank you!!
Carlos

What libcouchbase version do you use? And yes, it seems like the main problem is those undefined symbols (I guess old libcouchbase headers), rather than macro I fixed with the patch (which was just compiler warning).

libcouchbase 2.7.1

Thank you!!
Carlos

it seems like it found your libcouchbase successfully, could you post output of these commands?

grep -n LCB_VERSION /usr/local/include/libcouchbase/configuration.h
grep -n N1XSPEC_T_DEFAULT /usr/local/include/libcouchbase/ixmgmt.h

to make sure that that symbol is actually defined

Reinstalled the library has worked. Thanks you!!!

I’m just curious, how does SLES 11.3 relates to openSUSE? It seems like openSUSE 11.4 is not maintained at the moment, and package base is pretty old (php 5.3 and cmake too old to build libcouchbase).