Error building : fatal error: pcre.h: No such file or directory

The latest version of Phalcon uses PCRE libraries.

You can install them like so:

sudo apt-get install libpcre3-dev

and then try and install Phalcon again

For CentOS you will need to use

sudo yum install pcre-devel

Credits: @xgretsch

For Mac you can use

brew install pcre

Credits @Brandon Romano

For Mac without brew

Go to https://www.pcre.org/ and download latest pcre:,

tar -xzvf pcre-8.42.tar.gz
cd pcre-8.42
./configure --prefix=/usr/local/pcre-8.42
make
make install
ln -s /usr/local/pcre-8.42 /usr/sbin/pcre
ln -s /usr/local/pcre-8.42/include/pcre.h /usr/include/pcre.h

Credits @user1377324


To include pcre.h file, search the package archives for the pcre.h file. To do this I use a command called apt-file (

apt-get install apt-file

and

apt-file update

if you don’t have it installed).

Then search for the pcre package:

apt-file search -x "/pcre.h$"

The -x informs the command that I want to use a regular expression as the pattern. apt-file provided me with three hits:

  • kannel-dev: /usr/include/kannel/gwlib/pcre.h
  • libajax6-dev: /usr/include/ajax/pcre.h
  • libpcre3-dev: /usr/include/pcre.h

The last one is the one I want:

apt-get install libpcre3-dev

This will solve the problem with pcre.h file compilation problem. Hope it will help others, who may come to find an answer to this thread.


For mac osx maverick you can use

brew install pcre

if it gives you error, you can use

sudo ln -s /opt/local/include/pcre.h /usr/include/
sudo pecl install apc 

I have installed pcre via homebrew in Big Sur, so linked as:

sudo ln -s /opt/homebrew/include/pcre2.h /usr/local/include/