Skip to content

PECL memcached compile error.

If you are trying to compile PHP memcached module , you may likely will encounter this error message when ‘make’ command is executed.

root@blusmurf ~/memcached-2.1.0# make
/bin/sh libtool --mode=compile cc -I/usr/include/php  -I. -I/root/memcached-2.1.0 -DPHP_ATOM_INC -Iinclude -Imain -I/root/memcached-2.1.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c php_memcached.c -o php_memcached.lo
mkdir .libs
 cc -I/usr/include/php -I. -I/root/memcached-2.1.0 -DPHP_ATOM_INC -Iinclude -Imain -I/root/memcached-2.1.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c php_memcached.c  -fPIC -DPIC -o .libs/php_memcached.o
In file included from php_memcached.h:22,
                 from php_memcached.c:47:
php_libmemcached_compat.h:5:40: error: libmemcached-1.0/memcached.h: No such file or directory
In file included from php_memcached.c:47:
php_memcached.h:103: error: expected specifier-qualifier-list before 'memcached_st'
php_memcached.c:191: error: expected specifier-qualifier-list before 'memcached_st'
php_memcached.c:224: error: expected specifier-qualifier-list before 'memcached_stat_st'
php_memcached.c:306: error: expected declaration specifiers or '...' before 'memcached_return'
php_memcached.c:316: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'php_memc_do_cache_callback'
php_memcached.c:317: error: expected declaration specifiers or '...' before 'memcached_result_st'
php_memcached.c:318: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'php_memc_do_serverlist_callback'
php_memcached.c:319: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'php_memc_do_stats_callback'
php_memcached.c:320: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'php_memc_do_version_callback'
php_memcached.c: In function 'zim_Memcached___construct':
php_memcached.c:419: error: 'struct memc_obj' has no member named 'memc'
php_memcached.c:420: error: 'struct memc_obj' has no member named 'memc'
<!-- A lot of undeclared error -->
php_memcached.c:3734: error: 'MEMCACHED_TIMEOUT' undeclared (first use in this function)
php_memcached.c:3735: error: 'MEMCACHED_BAD_KEY_PROVIDED' undeclared (first use in this function)
php_memcached.c:3736: error: 'MEMCACHED_STORED' undeclared (first use in this function)
php_memcached.c:3737: error: 'MEMCACHED_DELETED' undeclared (first use in this function)
php_memcached.c:3738: error: 'MEMCACHED_STAT' undeclared (first use in this function)
php_memcached.c:3739: error: 'MEMCACHED_ITEM' undeclared (first use in this function)
php_memcached.c:3740: error: 'MEMCACHED_NOT_SUPPORTED' undeclared (first use in this function)
php_memcached.c:3741: error: 'MEMCACHED_FETCH_NOTFINISHED' undeclared (first use in this function)
php_memcached.c:3742: error: 'MEMCACHED_SERVER_MARKED_DEAD' undeclared (first use in this function)
php_memcached.c:3743: error: 'MEMCACHED_UNKNOWN_STAT_KEY' undeclared (first use in this function)
php_memcached.c:3744: error: 'MEMCACHED_INVALID_HOST_PROTOCOL' undeclared (first use in this function)
php_memcached.c:3745: error: 'MEMCACHED_MEMORY_ALLOCATION_FAILURE' undeclared (first use in this function)
php_memcached.c:3746: error: 'MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE' undeclared (first use in this function)
make: *** [php_memcached.lo] Error 1

Root cause

This /root/memcached-2.1.0/php_libmemcached_compat.h include line is pointed to non-existence memcache.h file hence failing the building process due to missing variables.

Solution

Modify /root/memcached-2.1.0/php_libmemcached_compat.h and point to the correct memcache.h file.

#ifndef PHP_LIBMEMCACHED_COMPAT
#define PHP_LIBMEMCACHED_COMPAT

/* this is the version(s) we support */
#include </usr/include/libmemcached/memcached.h>

#endif

Run ‘make’ again. The error should be gone unless if you have dependencies problem.

Published inTutorials

One Comment

  1. It almost fixed my problem but I have another compiling errors.
    “php_memcached.c:3685: error: ‘MEMCACHED_BEHAVIOR_TCP_KEEPALIVE’ undeclared (first use in this function)” and many many others.

    fuckin’ memcached 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.