When compiling and installing a Perl module from source via CPAN or CPANM (CPANMinus) on Linux such as RHEL, CentOS and Ubuntu, a compiling error may occur when running the Makefile.

The error message shown can vary, but generally it looks like one of the following:

Executing /usr/bin/perl Makefile.PL && make ..

This distribution requires a working compiler at Makefile.PL line 52.

Running Makefile.PL
Configuring Moose-2.1402 … cc: error trying to exec ‘cc1’: execvp: No such file or directory
This distribution requires a working compiler at Makefile.PL line 52.
Configure failed for Moose-2.102. See build.log for details.

Perl No Compiler

To resolve the error, install the gcc, the GNU Compiler Collection.

To install gcc compiler in Red Hat Enterprise Linux (RHEL), CentOS and related distributions, use the following command:

$ sudo yum install gcc

Alternatively, if you want to install all development tools, you can use the following command to install essential packages for developers:

$ sudo yum group install "Development Tools"

If you’re using Debian, Ubuntu and their variants, you can install all the essential development-related compilers together with their required prerequisite packages.

$ sudo apt-get install build-essential