简体   繁体   中英

sudo pecl install mongodb problem | unknown type name 'pcre_cache_entry'

I'm trying to install mongodb exentsion for php 8.0.13 on my MacOS Monterey.

I try sudo pecl install mongodb command: and then get below errror.

/opt/homebrew/Cellar/php@8.0/8.0.13/include/php/ext/spl/spl_iterators.h:151:4: error: unknown type name 'pcre_cache_entry'
                    pcre_cache_entry *pce;
                    ^
1 error generated.
make: *** [php_phongo.lo] Error 1
ERROR: `make' failed

在此处输入图像描述

which php: /opt/homebrew/bin/php php -v: PHP 8.0.13 (cli) (built: Nov 28 2021 13:11:14) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.13, Copyright (c) Zend Technologies with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Can anyone help me for fix this error? Thanks for your attention!

To compile MongoDB using PECL you will have to copy the pcre2.h to php's include directory.

For php@8.0, you can do this, But you will have to do this after every PHP release or if you switch the PHP version.

pcre2_h="$(find "$(brew --cellar pcre2)" -name "pcre2.h")"
cp -f "$pcre2_h" "$(brew --cellar php@8.0)"/*/include/php/ext/pcre

To avoid this I would recommend using shivammathur/extensions brew tap for installing PHP extensions.

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