php-memcached-dev / php-memcached

memcached extension based on libmemcached library
Other
991 stars 323 forks source link

compilation error when sasl.h is missing #341

Closed grikdotnet closed 6 years ago

grikdotnet commented 7 years ago

Error compiling memcached extension even having sasl disabled in configure.

# pecl download redis memcached
# cd memcached-3.0.3/
# phpize
 # ./configure --disable-memcached-sasl
...
checking for libmemcached... yes, shared
checking whether to enable memcached session handler support... yes
checking whether to enable memcached igbinary serializer support... no
checking whether to enable memcached json serializer support... no
checking whether to enable memcached msgpack serializer support... no
checking whether to enable memcached sasl support... no
checking whether to enable memcached protocol support... no
...
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
# make
...
 cc -I/usr/local/include/php -I. -I/usr/local/memcached-3.0.3 -DPHP_ATOM_INC -I/usr/local/memcached-3.0.3/include -I/usr/local/memcached-3.0.3/main -I/usr/local/memcached-3.0.3 -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 -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 -c /usr/local/memcached-3.0.3/php_memcached.c  -fPIC -DPIC -o .libs/php_memcached.o
In file included from /usr/include/libmemcached-1.0/memcached.h:85:0,
                 from /usr/include/libmemcached/memcached.h:39,
                 from /usr/local/memcached-3.0.3/php_libmemcached_compat.h:21,
                 from /usr/local/memcached-3.0.3/php_memcached_private.h:28,
                 from /usr/local/memcached-3.0.3/php_memcached.c:25:
/usr/include/libmemcached-1.0/struct/sasl.h:39:23: fatal error: sasl/sasl.h: No such file or directory
compilation terminated.
Makefile:194: recipe for target 'php_memcached.lo' failed
make: *** [php_memcached.lo] Error 1

For some reason there is an unconditional #include <libmemcached-1.0/struct/sasl.h> in memcached.h

OS: Alpine linux 3.4.6

runphp commented 7 years ago

I have the same problem, this config was ok

ENV MEMCACHED_VERSION=3.0.3
# compile memcached extension
ENV MEMCACHED_DEPS zlib-dev libmemcached-dev cyrus-sasl-dev
RUN set -xe \
    && apk add --no-cache libmemcached-libs zlib \
    && apk add --no-cache --virtual .memcached-deps $MEMCACHED_DEPS \
    && curl -fsSL http://pecl.php.net/get/memcached-${MEMCACHED_VERSION}.tgz -o memcached.tar.gz \
    && mkdir -p /tmp/memcached \
    && tar -xf memcached.tar.gz -C /tmp/memcached --strip-components=1 \
    && rm memcached.tar.gz \
    && docker-php-ext-configure /tmp/memcached --enable-memcached \
    && docker-php-ext-install /tmp/memcached \
    && rm -r /tmp/memcached
lt commented 6 years ago

This is not a bug/issue with the php-memached extension itself. Regardless of --disable-memcached-sasl being set, it's for toggling behaviour in the PHP extension, and has no effect on the headers provided by libmemached-dev.

You're going to need to satisfy the dependency to build, even if you opt-out of the functionality in the extension itself.

apk add cyrus-sasl-dev
grikdotnet commented 6 years ago

Got it. So, the bug is a missing check for sasl.h in a configure script.

lt commented 6 years ago

@grikdotnet No, sorry I realise I could have worded it better. There is no bug,

The provided libmemcached header that contains all of the function definitions to link against the libmemcached library has a hard dependency on sasl.h.

The compiler needs to know what is in that file (it could be anything!), even if you don't use what is in that file, it needs to know what is in it just in case.

This is not a bug, it is a missing build dependency on your side.

grikdotnet commented 6 years ago

One of a configure script goals is to check dependencies. Whether you accept that this missing dependency check is a bug or not, does not matter. It is missing.