Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed loading xdebug did found mach-o, but wrong architecture for php7

Whether I install via homebrew:

brew install homebrew/php/php70-xdebug

or compile from source located at http://xdebug.org using either just ./configure or the following:

./configure --enable-xdebug CC="gcc -arch i386" CXX="g++ -arch i386"
make

I still receive the following when running php7 that is bundled with Acquia DevDesktop:

Failed loading /Applications/DevDesktop/php7_0/ext/xdebug.so:  dlopen(/Applications/DevDesktop/php7_0/ext/xdebug.so, 9): no suitable image found.  Did find:
    /Applications/DevDesktop/php7_0/ext/xdebug.so: mach-o, but wrong architecture

Things I have confirmed:

  • I am copying the xdebug.so into the proper directory either from /usr/local/Cellar/php70-xdebug/2.4.0 (in the case of the homebrew install)
  • or from the newly compiled one from xdebug-2.4.0/module
  • which php returns /Applications/DevDesktop/php7_0/bin/php
  • php -i shows the correct .ini file (/Applications/DevDesktop/php7_0/bin/php.ini) and no others
  • opcache.so is turned off
  • zend_extension="/Applications/DevDesktop/php7_0/ext/xdebug.so" is in the php.ini

The full message php --version returns is:

$ php --version
Failed loading /Applications/DevDesktop/php7_0/ext/xdebug.so:  dlopen(/Applications/DevDesktop/php7_0/ext/xdebug.so, 9): no suitable image found.  Did find:
    /Applications/DevDesktop/php7_0/ext/xdebug.so: mach-o, but wrong architecture
PHP 7.0.4 (cli) (built: Mar 18 2016 02:12:27) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

The OS is a brand-new install of Mac OS 10.11.5 on a MacBook Air.

Does anyone know why is it complaining about the wrong architecture?

like image 405
André Angelantoni Avatar asked Oct 18 '22 05:10

André Angelantoni


1 Answers

This is what worked for me for DevDesktop:

  1. Download and extract the xdebug source code (I used xdebug-2.5.5).
  2. $ cd xdebug-2.5.5
  3. $ /Applications/DevDesktop/php7_0/bin/phpize

and now the step that was the one that caused most grief figuring out...

  1. $ ./configure --with-php-config=/Applications/DevDesktop/php7_0/bin/php-config CC="gcc -arch i386" CXX="g++ -arch i386"
  2. $ make
  3. $ cp modules/xdebug.so /Applications/DevDesktop/php7_0/ext/

  4. open the php7_0/bin/php.ini file and (assuming it is the default) replace:

    zend_extension="/Applications/DevDesktop/php5_6/ext/opcache.so"

with

;zend_extension="/Applications/DevDesktop/php5_6/ext/opcache.so"
[Xdebug]
zend_extension="/Applications/DevDesktop/php7_0/ext/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
  1. Stop and Start the server instance in DevDesktop and debug away.
like image 56
sdmeyers Avatar answered Oct 21 '22 10:10

sdmeyers