3

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
Žan Kusterle
  • 572
  • 1
  • 10
  • 28

2 Answers2

1

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.

Raber
  • 2,040
  • 16
  • 13
  • I managed to compile memcached and now I get a different error in php logs: 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 – Žan Kusterle Dec 23 '12 at 17:35
  • I guess I should install older version of compiler, but how to do this? For example apt-get install g++-4.2.0 doesn't work. I know I'm newbie... – Žan Kusterle Dec 23 '12 at 17:42
  • this error i don't understand :( btw. can you tell why your php is 32bit? – Raber Dec 23 '12 at 17:49
  • I don't think there's a 64bit version of xampp at the moment – Žan Kusterle Dec 23 '12 at 17:52
1

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.

Satish
  • 16,544
  • 29
  • 93
  • 149
  • Thanks, this works! I awarded bounty to you, but accepted Raber's answer since I want both of you to get some reputation – Žan Kusterle Dec 28 '12 at 23:10