Question

ORIGINAL POST

First of all, I want to install memcached, not memcache.

I'm trying to set up memcached to work with my lampp server on ubuntu 12.10 since yesterday. I've already followed almost every tutorial I could find. The most recent thing, I tried to do was:

in terminal

apt-get install libmemcached-dev 
cd /opt/lampp
./bin/pecl install memcached

and then adding extension="memcached.so" in php.ini file. After this I restarted lampp using /opt/lampp/lampp restart

When I tried to open php script in my browser it just got downloaded. Running tail -20 /opt/lampp/logs/php_error_logthis is what I see:

PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/memcached.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/memcached.so: wrong ELF class: ELFCLASS64 in Unknown on line 0

It seems this guy had same problem but with different extension. When I try to compile 32 bit version of the extension using:

phpize
CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure
make

But make throws the following error:

/usr/bin/ld: skipping incompatible /usr/local/lib/libmemcached.so when searching for -lmemcached
/usr/bin/ld: cannot find -lmemcached
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
make: *** [memcached.la] Error 1

The problem is that I don't even know if I'm on the right path. If someone could write short step-by-step guide how to get this working or just show me where the issue is it would be great.

UPDATE

After executing sudo dpkg --add-architecture i386 sudo apg-get update sudo apt-get install libmemcached-dev:i386 libz-dev:i386 and phpize CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure make memcached compiles fine. It still doesn't work however. After checking php error logs again I get this

PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/memcached.so' - /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6) in Unknown on line 0
Was it helpful?

Solution

You are on the right path - your lampp is 32bit while rest of the system (i assume) is 64bit. So when you installed libmemcached an compiled php-libmemcached it is 64bit version. That's why you get the "Wrong ELF class" error.

Before you can compile 32bit version of php-memchached you need to install 32bit versions of libmemcached and libz (and their headers).

You need to: sudo dpkg --add-architecture i386 sudo apg-get update sudo apt-get install libmemcached-dev:i386 libz-dev:i386

I think that should be enough to let you compile 32bit version of php-libmemcached.

OTHER TIPS

There is a dirt way to fix your problem

go to /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.x.x

and copied the libgcc_s.so into

/opt/lampp/lib and renamed it to libgcc_s.so.1 to overwrite the previous file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top