How to fix "configure: error: pcre.h not found"

Last updated on September 11, 2020 by Dan Nanni

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

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean