At my job, I use a Solaris distribution as a development server and the package manager doesn't propose the Xdebug package so I need to use the PECL command, which is fine. But, the PECL manager uses the system compiler which compiles binaries with 32 bits flags although my LAMP stack is 64 bits linked.

No other choice to compile manually my extension and after a few hours of hell (yes, I'm not a C pro :cwy:), I found how to compile correctly my extension.

So, if one day you need to compile a PHP extension in a different architecture, here's the solution (at least, it worked for Solaris).

Here are the steps to compile Xdebug using the default configuration:

git clone https://github.com/derickr/xdebug.git
cd xdebug
phpize
./configure --enable-xdebug
make
cp modules/xdebug.so /path/to/your/php/extensions/dir/
echo "zend_extension=\"/path/to/your/php/extensions/dir/xdebug.so\"" >> /path/to/your/php.ini
php -v
PHP 5.3.8 (cli) (built: Dec  6 2011 20:23:50) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.3.0dev, Copyright (c) 2002-2012, by Derick Rethans

Now, if we want it to use the 64 bits architecture, we will need to add some extra variable declaration before we configure the extension:

CFLAGS=-m64 CPPFLAGS=-m64 CCASFLAGS=-m64 ./configure --enable-xdebug

To make sure it's well 64 bits, run the following command:

file modules/xdebug.so
modules/xdebug.so:      ELF 64-bit LSB dynamic lib AMD64 Version 1, dynamically linked, not stripped, no debugging information available

Here we are! Looks easy but not really when you're not accustomed to that kind of problem, especially when using a OS you don't know ;).
I added a note on the PHP documentation about this trick =P.

See ya later!


Joris Berthelot