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

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

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

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

When compiling native PHP extensions like Phalcon, the build process often halts with a cryptic message about missing header files. The specific error fatal error: pcre.h: No such file or directory indicates that the compiler cannot locate the header definitions required for the PCRE (Perl Compatible Regular Expressions) library. This is a dependency issue, not a problem with the Phalcon source code itself.

Looking at the command you executed, you installed several PHP modules including php5-curl, php5-memcache, and development tools like gcc. However, the standard LAMP stack installation on Ubuntu 13.10 does not automatically include the development libraries for every extension it compiles. The error log clearly points to /usr/include/php5/ext/pcre/ expecting to find pcre.h, which implies that while the PHP engine might be linked against PCRE at runtime, the compile-time headers are missing from your system include path.

To resolve this on Ubuntu 13.10, you need to install the specific development package that provides these headers. The package name usually follows the pattern of the library plus -dev. For PCRE, this is libpcre-dev. You can add this to your existing installation command:

sudo apt-get install -y libpcre-dev

After installing the missing header file, you must clean and rebuild Phalcon. If you left the previous build artifacts in the directory, they might still reference the old configuration or cached include paths. Run make distclean or simply remove the build directory entirely before re-running your compilation script:

rm -rf build/32bits/*
# Re-run your original Phalcon build commands here

There is a subtle but important distinction between runtime dependencies and development dependencies in Linux environments. A library like libpcre3 provides the functions that PHP uses when running, but libpcre-dev contains the header files (pcre.h) and static libraries needed to compile C extensions against it. It is common for developers to install the runtime packages and assume headers are present, leading to exactly this type of compilation failure.

If you are moving forward with Phalcon on this version of Ubuntu, consider also installing php5-dev. While you listed it in your command block, it is worth ensuring it is actually installed and that the PHP include path in your CMakeLists.txt or Makefile matches the version of PHP installed (in this case, /usr/include/php5). Mismatched PHP versions between the runtime engine and the headers can cause further linking errors later in the build process.

For modern projects, relying on system packages for complex C extensions like Phalcon can become cumbersome due to dependency hell and version mismatches. If you find yourself spending too much time resolving header dependencies for legacy extensions, it might be worth evaluating whether a pre-compiled binary release matches your exact PHP environment or if migrating to a containerized setup (like Docker) would isolate these compilation complexities.

If you are transitioning from Phalcon to a more modern PHP framework stack, Laravel provides a robust alternative that abstracts much of the underlying system configuration. You can explore their resources at https://laravelcompany.com, which offers documentation and guides for setting up modern development environments where such low-level compilation errors are less frequent due to better dependency management tools.

Our network