How to install PECL PHP extension on 64bit linux while you are using 32bit XAMPP

Submitted by ivica on Sun, 24.07.2011

OK, here is a problem. I wanted to play a little bit with uploadprogress PECL extension. Normally installation of PECL extension is very easy, you just do

$cd /opt/lampp
$sudo ./bin/pecl install uploadprogress

form console and PECL installer would do the rest, which was my case also - extension was downloaded from Internet and compiled successfully. After adding extension="" to php.ini and restarting XAMPP I've got next error

$ sudo ./lampp restartapache
XAMPP: Stopping Apache with SSL...
Warning: PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/ wrong ELF class: ELFCLASS64 in Unknown on line 0

Running file on confirmed that system compiled 64bit version of library

$ file lib/php/extensions/no-debug-non-zts-20090626/
lib/php/extensions/no-debug-non-zts-20090626/ ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped

When you sit back and think for a moment, this is actually OK because I am running 64bit version of Kubuntu and 32bit version of XAMPP (there is no 64bit version of XAMPP for now) for my development environment, so my C compiler and linker are 64bit and will produce 64bit libraries.

Here is a solution for this situation.

First you need to add 32bit libraries for compilation, for example on ubuntu systems this would look like

$sudo apt-get install g++-multilib

Then you need to manually download PHP PECL extension that you want

$cd /opt/lampp
$tar xzf uploadprogress-1.0.1.tgz
$cd uploadprogress

Now if you have multiple PHP installed, like I do, you need to tell in console which one you want to use currently. I for example have /usr/bin/php installed from my package manager, but my main php is in my XAMPP which is on /opt/lampp/bin path. So first you need to find out which php you are currently using in console

$which php
$which php

Now we are ready to compile and link our PHP extension

$CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure

This m32 flags are telling compiler to create 32bit extension. All we have to do now is to copy our new extension to current XAMPP PHP extension directory

$cp modules/ /path_to_ext_lib

And then add "" to our php.ini.

That's it, we now have 32bit version of PHP extension which is compatible with our XAMPP installation.

Note: if you are getting following error when trying to restart apache or when you start php from command line

Warning: PHP Startup: uploadprogress: Unable to initialize module
Module compiled with module API=20060613
PHP    compiled with module API=20090626
These options need to match

That actually means that you have compiled PECL extension against wrong PHP header files - which was exactly the error I have done. I upgraded XAMPP couple of times in the past, but didn't refresh development packages. Downloading latest development package from and updating my XAMPP installation fixed this - of course you need to recompile extension again.


1 comment

by aj on Sun, 06.12.2015

Thank you for this post. It saved me a ton of time!