I've looked around several other questions like this one, guide like this or this but I still had no luck.
Here's what i've done so far:
- Downloaded gmp with brew using
brew install autoconf gmp
- Downloaded PHP (i'm using version 7.3.24) from source
- Copied Gmp directory to
/Applications/MAMP/bin/php/php7.3.24/include/php/ext
- Entered that dir and launched
phpize
- Launched
./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.24/bin/php-config
- Launched
make
- Launched
make install
So far, so good. No errors, all seems fine but if i look at this point to my cli php -m
(or php -i
) there's no gmp extension loaded. So i went to my cli php.ini
file and my web php.ini
file and manually added extension=gmp.so
(the file exist in this path /Applications/MAMP/bin/php/php7.3.24/include/php/ext/gmp/modules/gmp.so
).
I even tried to specify the full path, but still no luck. Neither my cli or my phpinfo();
shows GMP enabled. I'm kinda confused atm and can't think about anything else.
What am I missing? Obviously, I restarted MAMP PRO like a dozen times, even my mac itself.
- MacOs version: 11.4 Big Sur on iMac 24' M1
- MAMP PRO Version: 6.3.1
- PHP Version used: 7.3.24
Update 08/07/21
I updated MAMP PRO and it installed PHP version 7.3.27 so i went all over it again, download php from source https://github.com/php/php-src/releases?after=php-8.0.4RC1, copied ext/gmp into
/Applications/MAMP/bin/php/php7.3.27/include/php/ext
, launched /Applications/MAMP/bin/php/php7.3.27/bin/phpize
, ./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.27/bin/php-config
, make
and make install
. No errors.
Output of make install
is:
Installing shared extensions: /Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/
Installing header files: /Applications/MAMP/bin/php/php7.3.27/include/php/
shtool:install:Warning: source and destination are the same - skipped
I added extension=gmp.so
to php.ini
via MAMP interface, file, edit template -> php -> php7.3.27. Restarted MAMP and nothing new on phpinfo();
Update 12/07/21
As per Hakre request i've run the following command into cli and this is the result:
[~]$ php -n -d extension=gmp.so -i
PHP Warning: PHP Startup: Unable to load dynamic library 'gmp.so' (tried: /Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so (dlopen(/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so, 9): no suitable image found. Did find:
/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so: mach-o, but wrong architecture
/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so: mach-o, but wrong architecture), /Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so.so (dlopen(/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so.so, 9): image not found)) in Unknown on line 0
phpinfo()
PHP Version => 7.3.27
which is quite interesting if you look at this img
The extension actually exists
For Raptor:
This is the output of the commands you've asked.
[~]$ which php
/Applications/MAMP/bin/php/php7.3.27/bin/php
[~]$ php --ini | grep "Loaded Configuration File"
Loaded Configuration File: /Applications/MAMP/bin/php/php7.3.27/conf/php.ini
[~]$ php --version
PHP 7.3.27 (cli) (built: Mar 16 2021 12:04:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
[~]$
Ofc there are multiple php's installed since MAMP alone fill it with like 4-5 version + there's the default one from MacOSx which i've overwrote with .zshrc bash profile
export PATH=/Applications/MAMP/bin/php/php7.3.27/bin:$PATH
That line is from my .zshrc
Could the issue be related to the new M1 chip? I'm using a new iMac bought just at the end of June2021. Maybe is this related?
For Haridarshan:
Let me start saying that i tried to use .configure with no additional params, then i tried with CC="gcc -arch i386" CXX="g++ -arch i386" and even with CC="gcc -arch arm64" CXX="g++ -arch arm64" (i found arm64 in configure.log). None of them produced a valid .so, if i didn't miss any other info from the command line. About the test u've asked me to make, this is the result:
[~]$ file /Applications/MAMP/bin/php/php7.3.27/bin/php
/Applications/MAMP/bin/php/php7.3.27/bin/php: Mach-O 64-bit executable x86_64