Tuesday, April 3, 2012

Hot to compile pecl extension as 32 bit on 64 bit linux

  • Download the source of pecl package.
  • Untar it to some temporary location
  • Go to folder with extracted tar an run phpize to make ./config file.
  • Set flags to compile it as 32 bit application
    CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure
  • make
  • make install

Don't forget to install 32 bit compiler:

sudo apt-get install g++-multilib

UPDATE !!! If you connect to external services like memcached, solr etc. then you will come to a dead end, because of linking problem. There are 2 things you can do:

  • Create 32bit vitrual machine, install the 32bit lampp and compile all the pecl extesions you need and then transfer in to 64bit machine, and you will end up coping 32bit dependency librarires to 64bit machine (like I did).
  • Make your own 64bit lampp stack from source or simply use one already made like bitnami.

To conclude I've learned that you can have 32bit lampp stack on 64bit system as long as you stick do default (PHP,MYSQL, APACHE) bundle. If you need external services (memcached, solr ...) and want't to compile extensions that references them, you are done.
P.S. Don't use lampp unless you realy need it (to support some legacy code ...). Otherwise use packages that come with system