How to fix “configure: error: pcre.h not found”

Question:When I try to compile a program, it fails with the following error. How can I fix this error on [insert your Linux distro]?

configure: error: pcre.h not found ...

pcre.h is a development header file for PCRE (Perl Compatible Regular Expressions), which is a C library for pattern-matching regular expressions whose syntax and semantics are inspired by the Perl language. More powerful and flexible than POSIX regular expressions, PCRE is popularly used by many open-source projects such as Apache HTTP server, PHP, Postfix, Nmap, etc. There are also PCRE wrappers written in different languages (e.g., C++, PHP, .NET, Java) and built around PCRE API specification.

The error "configure: error: pcre.h not found" indicates that your Linux system does not have PCRE development files installed.

To install PCRE library and development header files, do the following.

Install PCRE on Ubuntu, Debian, Linux Mint

$ sudo apt-get install libpcre3-dev

Install PCRE on CentOS, Fedora, RHEL

$ sudo yum install pcre-devel

Install PCRE from the Latest Source

If you want to build and install PCRE library and development files from the latest source, you can do the following.

Prior to building, install build dependencies on Debian-based system:

$ sudo apt-get install gcc g++ make

Prior to building, install build dependencies on Red Hat-based system:

$ sudo yum install gcc gcc-c++ make

Finally, compile and install PCRE as follows. To customize build options, you can pass additional parameters (e.g., --prefix=/opt) to the configure script. To check available build options, you can run "./configure --help"

$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
$ tar -xf pcre-8.38.tar.gz
$ cd pcre-8.38
$ ./configure
$ make
$ sudo make install

Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

Leave a comment

Your email address will not be published. Required fields are marked *