简体   繁体   中英

pcre2.h: No such file or directory

I try to install openswoole on my mac machine. I have this issue when installing it.

/usr/local/Cellar/php@7.4/7.4.29/include/php/ext/pcre/php_pcre.h:25:10: fatal error: pcre2.h: No such file or directory
 #include "pcre2.h"

I used the command brew install pcre to fix this issue as others recommend, but I always get the same result. I try to open the folder pcre I only see one php_pcre.h file inside it.

try:

sudo ln -s /opt/local/include/pcre.h /usr/include/       "replace your file location here"
sudo pecl install apc 

Here's simplest solution. I have finally solved my problem. I used PHP 8.1.7 - Mac Pro 2022 - Apple Silicon (M1)

My errors: fatal error: 'pcre2.h' file not found

The solution that I used:

1. brew install pcre2

2. ln -s /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /opt/homebrew/Cellar/php/8.1.7/include/php/ext/pcre/pcre2.h 

Please check your path again when use `ln -s` 

3. sudo pecl install ... something you want to install :) **openswoole** with you :).

Success Installation:

在此处输入图像描述

Hope it help you :) Thanks

For M1 MacBooks, this is how I fixed that error when installing rdkafka.

pecl install rdkafka

Error

/Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
         ^~~~~~~~~

Solution

ln -s /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre/pcre2.h

See the new link

➜ cd /Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre
➜ ls -l
total 8
lrwxr-xr-x  1 ddhondup  admin    48 Oct  6 15:29 pcre2.h -> /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h
-rw-rw-r--  1 ddhondup  admin  3970 Oct  1  2021 php_pcre.h

After adding the link, it worked.

Build process completed successfully
Installing '/Applications/MAMP/bin/php/php8.0.8/lib/php/extensions/no-debug-non-zts-20200930/rdkafka.so'
install ok: channel://pecl.php.net/rdkafka-6.0.3
configuration option "php_ini" is not set to php.ini location
You should add "extension=rdkafka.so" to php.ini

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM