swoole-src: Compile Error on Mac Big Sur with PHP 8
Please answer these questions before submitting your issue. Thanks!
- 
What did you do? If possible, provide a simple script for reproducing the error. Install swoole pecl install swoole
- 
What did you expect to see? swoole pecl extension 
- 
What did you see instead? Compile termination error 
In file included from /private/tmp/pear/temp/swoole/ext-src/php_swoole.cc:21:
/usr/local/Cellar/php/8.0.0_1/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
         ^~~~~~~~~
1 error generated.
make: *** [ext-src/php_swoole.lo] Error 1
ERROR: `make' failed
- What version of Swoole are you using (show your php --ri swoole)?
pecl install swoole
downloading swoole-4.5.9.tgz ...
Starting to download swoole-4.5.9.tgz (1,552,445 bytes)
..................................................................................................................................................................................................................................................................................................................done: 1,552,445 bytes
351 source files, building
running: phpize
Configuring for:
PHP Api Version:         20200930
Zend Module Api No:      20200930
Zend Extension Api No:   420200930
- What is your machine environment used (show your uname -a&php -v&gcc -v) ?
Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_6
PHP 8.0.0 (cli) (built: Nov 30 2020 13:51:52) ( NTS ) Copyright © The PHP Group Zend Engine v4.0.0-dev, Copyright © Zend Technologies with Zend OPcache v8.0.0, Copyright ©, by Zend Technologies
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 28 (3 by maintainers)
I can get it work by manually symlink the required file.
https://github.com/swoole/swoole-src/issues/3926#issuecomment-744763791
For me the paths were different, this worked:
I had similar problem with PHP 7.4 on Mac M1, but changing the versions in the code above did not work. The
pcre2.hfile was in a different directory all together, once i found the correct location it compiled.This worked for me with PHP 8.0.5 and pcre2 10.36:
in my case it solved with: php 8.0.6 pcre2 10.36
For my case I did this in my Mac M1:
brew list pcre2 | grep 'pcre2\.h$'This will output the path to pcre2 as shown below:
/opt/homebrew/Cellar/pcre2/10.40/include/pcre2.hThen
ln -s /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /opt/homebrew/Cellar/php@7.4/7.4.30/include/php/ext/pcre/pcre2.hBe sure to replace the php path with your php version && path.
Hopefully this helps someone.
If you just installed
phpusing Brew without specifying a version, the path might be slightly different (again). This is the command I had to run:(where
X.X.Xis the PHP version, in my case8.1.4)ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include/php/ext/pcre/pcre2lib/pcre2.h /opt/homebrew/Cellar/php/8.0.3/include/php/ext/pcre/pcre2.hITS SAVED ME, THANKS!!!♥️
thanks
ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include/php/ext/pcre/pcre2lib/pcre2.h /opt/homebrew/Cellar/php/8.0.3/include/php/ext/pcre/pcre2.h
and then
Thanks, guys. In my case it solved it a symlink:
ln -s /opt/homebrew/include/pcre2.h /opt/homebrew/Cellar/php@7.4/7.4.24/include/php/ext/pcre/pcre2.hAll that you need is check your php version and path. In case of pcre2 is not installed, install it with:
brew install pcre2Environment and Case: Macbook M1 with Big Sur trying to install imagick extension with PHP 7.4
Just to simplify for others, where X - installed php version
sudo ln -s /opt/homebrew/include/pcre2.h /opt/homebrew/Cellar/php@X.X/X.X.X/include/php/ext/pcre/pcre2.hTry installing
pcre2to the system before:But I guess it can cause Swoole to be compiled with a different version of PCRE library than PHP’s.
Thanks, guys, you saved my time!
OK,if Your system version is : MacOS Big Sur 11.6 and is M1 ,This is useful… Thanks …
Thank you it was helpful, I did it for php 8.0.8_1 and it worked.