🦔
fatal error: 'pcre2.h' file not found, make: *** [pcov.lo] Error 1
peclインストール時に出るエラー。拡張のコンパイルに失敗している。以下はPCOV
$ pecl install pcov
/opt/homebrew/Cellar/php/8.1.9/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
1 error generated.
make: *** [pcov.lo] Error 1
ERROR: `make' failed
この場合内部のpcre拡張内部のpcre2.hの読み込みができていない。
/opt/homebrew/Cellar/php/8.1.9/include/php/ext/pcre/php_pcre.h
pcre2はHomebrewでインストールした
$ brew info pcre2
==> pcre2: stable 10.40 (bottled), HEAD
Perl compatible regular expressions library with a new API
https://www.pcre.org/
/opt/homebrew/Cellar/pcre2/10.40 (230 files, 6.1MB) *
Poured from bottle on 2022-08-31 at 11:32:39
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/pcre2.rb
License: BSD-3-Clause
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 287,214 (30 days), 864,172 (90 days), 3,549,534 (365 days)
install-on-request: 2,669 (30 days), 8,839 (90 days), 51,619 (365 days)
build-error: 5 (30 days)
ヘッダファイルはここにある
$ find /opt -name pcre2.h
/opt/homebrew/include/pcre2.h
C_INCLUDE_PATHを設定して見つかるようにする
C_INCLUDE_PATH=/opt/homebrew/include pecl install pcov
# C_INCLUDE_PATH=/opt/homebrew/opt/pcre2/include でもok
Discussion