PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'couchbase.so'


#1

I am trying to setup php to connect to couchbase and I get the following

PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) ‘couchbase.so

couchbase php extension was installed with:

pecl install couchbase

I’m on CENTOS 5 with php5.4.34


#2

Hey dartasura,

Would you be able to explain how you are installing the library?

Cheers, Brett


#3

Hi brett,

I have ssh access to my server i do:

pecl install couchbase

and i got this output:

Did not download optional dependencies: pecl/igbinary, use --alldeps to download automatically
pecl/couchbase can optionally use package "pecl/igbinary"
downloading couchbase-2.0.0.tgz …
Starting to download couchbase-2.0.0.tgz (23,250 bytes)
…done: 23,250 bytes
12 source files, building
running: phpize
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
Autoconf version 2.59 or higher is required for this script
building in /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0
running: /root/tmp/pear/couchbase/configure
checking for grep that handles long lines and -e… /bin/grep
checking for egrep… /bin/grep -E
checking for a sed that does not truncate output… /bin/sed
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 gcc44 accepts -g… yes
checking for gcc44 option to accept ISO C89… none needed
checking how to run the C preprocessor… gcc44 -E
checking for icc… no
checking for suncc… no
checking whether gcc44 and cc understand -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
checking for PHP includes… -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory… /usr/local/lib/php/extensions/no-debug-non-zts-20121212
checking for PHP installed headers prefix… /usr/local/include/php
checking if debug is enabled… no
checking if zts is enabled… no
checking for re2c… re2c
checking for re2c version… invalid
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk… gawk
checking whether to enable Couchbase support… yes, shared
checking for ANSI C header files… yes
checking for sys/types.h… yes
checking for sys/stat.h… yes
checking for stdlib.h… yes
checking for string.h… yes
checking for memory.h… yes
checking for strings.h… yes
checking for inttypes.h… yes
checking for stdint.h… yes
checking for unistd.h… yes
checking libcouchbase/couchbase.h usability… yes
checking libcouchbase/couchbase.h presence… yes
checking for libcouchbase/couchbase.h… yes
checking config.h usability… no
checking config.h presence… no
checking for config.h… no
checking couchbase.h usability… no
checking couchbase.h presence… no
checking for couchbase.h… no
checking datainfo.h usability… no
checking datainfo.h presence… no
checking for datainfo.h… no
checking exception.h usability… no
checking exception.h presence… no
checking for exception.h… no
checking phpstubstr.h usability… no
checking phpstubstr.h presence… no
checking for phpstubstr.h… no
checking for ld used by gcc44… /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld… yes
checking for /usr/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… 98304
checking command to parse /usr/bin/nm -B output from gcc44 object… ok
checking for objdir… .libs
checking for ar… ar
checking for ranlib… ranlib
checking for strip… strip
checking if gcc44 supports -fno-rtti -fno-exceptions… no
checking for gcc44 option to produce PIC… -fPIC
checking if gcc44 PIC flag -fPIC works… yes
checking if gcc44 static flag -static works… yes
checking if gcc44 supports -c -o file.o… yes
checking whether the gcc44 linker (/usr/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
checking whether the g++44 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries… yes
checking for g++44 option to produce PIC…
checking if g++44 static flag works… yes
checking if g++44 supports -c -o file.o… yes
checking whether the g++44 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries… yes
checking dynamic linker characteristics… GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs… unsupported
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/libtool --mode=compile gcc44 -I. -I/root/tmp/pear/couchbase -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/couchbase/couchbase.c -o couchbase.lo
mkdir .libs
gcc44 -I. -I/root/tmp/pear/couchbase -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/couchbase/couchbase.c -fPIC -DPIC -o .libs/couchbase.o
/bin/sh /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/libtool --mode=compile gcc44 -I. -I/root/tmp/pear/couchbase -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/couchbase/cluster.c -o cluster.lo
gcc44 -I. -I/root/tmp/pear/couchbase -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/couchbase/cluster.c -fPIC -DPIC -o .libs/cluster.o
/root/tmp/pear/couchbase/cluster.c: In function ‘zim_Cluster___construct’:
/root/tmp/pear/couchbase/cluster.c:176: warning: ‘lcb_set_error_callback’ is deprecated (declared at /usr/include/libcouchbase/deprecated.h:88)
/bin/sh /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/libtool --mode=compile gcc44 -I. -I/root/tmp/pear/couchbase -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/couchbase/bucket.c -o bucket.lo
gcc44 -I. -I/root/tmp/pear/couchbase -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/couchbase/bucket.c -fPIC -DPIC -o .libs/bucket.o
/root/tmp/pear/couchbase/bucket.c: In function ‘zim_Bucket___construct’:
/root/tmp/pear/couchbase/bucket.c:494: warning: ‘lcb_set_error_callback’ is deprecated (declared at /usr/include/libcouchbase/deprecated.h:88)
/bin/sh /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/libtool --mode=compile gcc44 -I. -I/root/tmp/pear/couchbase -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/couchbase/exception.c -o exception.lo
gcc44 -I. -I/root/tmp/pear/couchbase -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/couchbase/exception.c -fPIC -DPIC -o .libs/exception.o
/bin/sh /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/libtool --mode=link gcc44 -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/include -I/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/main -I/root/tmp/pear/couchbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -o couchbase.la -export-dynamic -avoid-version -prefer-pic -module -rpath /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/modules couchbase.lo cluster.lo bucket.lo exception.lo -lcouchbase
gcc44 -shared .libs/couchbase.o .libs/cluster.o .libs/bucket.o .libs/exception.o -Wl,–rpath -Wl,/usr/lib64 -Wl,–rpath -Wl,/usr/lib64 /usr/lib64/libcouchbase.so -L/usr/kerberos/lib64 -Wl,-soname -Wl,couchbase.so -o .libs/couchbase.so
creating couchbase.la
(cd .libs && rm -f couchbase.la && ln -s …/couchbase.la couchbase.la)
/bin/sh /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/libtool --mode=install cp ./couchbase.la /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/modules
cp ./.libs/couchbase.so /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/modules/couchbase.so
cp ./.libs/couchbase.lai /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/modules/couchbase.la
PATH="$PATH:/sbin" ldconfig -n /root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/modules

Libraries have been installed in:
/root/tmp/pear/pear-build-rootK1SmDj/couchbase-2.0.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:

  • add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
    during execution
  • add LIBDIR to the `LD_RUN_PATH’ environment variable
    during linking
  • use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
  • have your system administrator add LIBDIR to `/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

Build complete.
Don’t forget to run ‘make test’.

running: make INSTALL_ROOT="/root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0" install
Installing shared extensions: /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0/usr/local/lib/php/extensions/no-debug-non-zts-20121212/
running: find “/root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0” | xargs ls -dils
57049103 8 drwxr-xr-x 3 root root 4096 Oct 22 14:08 /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0
57049132 8 drwxr-xr-x 3 root root 4096 Oct 22 14:08 /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0/usr
57049133 8 drwxr-xr-x 3 root root 4096 Oct 22 14:08 /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0/usr/local
57049134 8 drwxr-xr-x 3 root root 4096 Oct 22 14:08 /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0/usr/local/lib
57049135 8 drwxr-xr-x 3 root root 4096 Oct 22 14:08 /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0/usr/local/lib/php
57049136 8 drwxr-xr-x 3 root root 4096 Oct 22 14:08 /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0/usr/local/lib/php/extensions
57049137 8 drwxr-xr-x 2 root root 4096 Oct 22 14:08 /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0/usr/local/lib/php/extensions/no-debug-non-zts-20121212
57049131 252 -rwxr-xr-x 1 root root 245787 Oct 22 14:08 /root/tmp/pear/pear-build-rootK1SmDj/install-couchbase-2.0.0/usr/local/lib/php/extensions/no-debug-non-zts-20121212/couchbase.so

Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20121212/couchbase.so’
install ok: channel://pecl.php.net/couchbase-2.0.0
Extension couchbase enabled in php.ini

but when i try to run the demo script:

<?php
$myCluster = new CouchbaseCluster('couchbase://localhost');
$myBucket = $myCluster->openBucket('default');
?>

i got a Class ‘CouchbaseCluster’ not found.

If i check the php error_log i have this error

PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'couchbase.so' in Unknown on line 0.

I also try to build the lib from source like that

wget http://pecl.php.net/get/couchbase-2.0.0.tgz
tar xf couchbase-2.0.0.tgz
cd couchbase-2.0.0
phpize
./configure
make
make test

and i got this:

=> ====================================================================
> PHP         : /usr/local/bin/php
> Warning: PHP Startup: Invalid library (maybe not a PHP library) 'couchbase.so' in Unknown on line 0

> PHP_SAPI    : cli
> PHP_VERSION : 5.5.18
> ZEND_VERSION: 2.5.0
> PHP_OS      : Linux - Linux ********* 2.6.18-371.9.1.el5 #1 SMP Tue Jun 10 17:49:56 EDT 2014 x86_64
> INI actual  : /root/couchbase-2.0.0/tmp-php.ini
> More .INIs  :
> CWD         : /root/couchbase-2.0.0
> Extra dirs  :
> VALGRIND    : Not used
> =====================================================================
> TIME START 2014-10-22 14:12:52
> =====================================================================
> No tests were run.

Best regards


#4

How are you specifying the couchbase binary to load?

Cheers, Brett


#5

i thought the problem was couchbase but it’s doing that for all pecl extension i try to install.
I think i gonna close this thread but thanks for your help anyway

Best regards, dart


#6

Ok i find why if someone have this problem one day it was because my autoconf version was to low


#7

Glad you got it fixed. Thank you for posting your resolution!

Cheers, Brett