This is something i've met while trying to install PHP-GMP extension.
What i was trying to do is:
brew install autoconf gmp
/Applications/MAMP/bin/php/php7.3.24/include/php/ext
phpize
As soon as i hit enter it starts doing it's stuff until it says:
configure: error: GNU MP Library version 4.2 or greater required.
Once i managed to solve this somehow but i really don't know how i did it. I can only remember of downloading the gmp .tar from the official website https://gmplib.org/#DOWNLOAD but then nothing works.
Let me say that i'm a total noob with those ./configure, make and make install stuff. I don't even know what is going on so all i did was random launching hoping something good could happen:
What i've tried after downloading the official .tar is entering the folder and go with:
I've also tried to do:
export CPPFLAGS="-I/usr/local/Cellar/gmp/include"
export LDFLAGS="-L/usr/local/Cellar/gmp/lib"
as suggested here but nothing changed. I even tried to add --prefix=/usr/local/Cellar to the ./configure command but no luck.
This all story is related to this other question of me where i was trying to go on with the issue when the ./configure was still working. Now it's like i went backwards.
Sidenote: i guess it all changed when i fired brew doctor, and brew cleanup. It must have destroyed something i made that brought me back to this state
Update 23/08/2022:
As i had to go throughout all over this again i think i have some more hint to give you for future reference, here's the list:
Install GMP via homebrew (if you have an old version of homebrew or you migrated datas between Intel Mac and M1 Mac then you need to UNINSTALL homebrew and INSTALL it all over again with all the libraries)
brew install autoconf gmp
Downloading php from source is necessary, so that you can grab the /ext/gmp directory and copy inside your current PHP version folder (for me it is currently Applications/MAMP/bin/php/php8.1.0/include/php/ext/)
You need to enter inside the gmp folder that you just copied inside Applications/MAMP/bin/php/php8.1.0/include/php/ext/gmp
The command i've launched that didn't give any errors about missing GMP was:
./configure
--with-php-config=/Applications/MAMP/bin/php/php8.1.0/bin/php-config CXXFLAGS="-I/opt/homebrew/Cellar/gmp/6.2.1_1/include
CPPFLAGS="-I/opt/homebrew/Cellar/gmp/6.2.1_1/include
LDFLAGS="-L/opt/homebrew/Cellar/gmp/6.2.1_1/lib"
launch make
launch make install
IMPORTANT NOTE: M1 is arm64 architecture and if you've installed brew correctly you should have a folder /opt/homebrew/Cellar/. Instead Intel is x86_64 and the brew folder was /usr/local/Cellar/
Old answer
Ok this was quicker then i thought but i should leave it here as a reference for everyone else which will hit the same issue.
TLDR;
You need to reinstall brew for the new architecture using this arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
and then install packages with this arch -x86_64 brew install <package>
.
Credits to emonz
Long version answer:
This issue all starts with brew, i don't even know why it wasn't giving me hints about this issue until just today. When i launched brew install gmp
it printed this error:
which lead me to this answer from emonz. After i finally reinstalled brew i could finally get the ./configure command to work using additional args:
./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.27/bin/php-config CC="gcc -arch x86_64" CXX="g++ -arch x86_64"
So basically it is all related to the new M1 chip i guess. I still don't know what i did in the past to solve this issue w/o upgrading brew to the new arch but somehow i did it. I'll leave the question and this answer more like a guide for future comers and give them hints of what they can try to solve the issue, i wish nobody go past this pain ever again.