I'm trying to install Crypt-SSLeay on a macbook and it failed.

I manually downloaded Crypt-SSLeay from cpan and issued:

 perl Makefile.pl

The error is

openssl-version.c:2:10: fatal error: 'openssl/opensslv.h' file not found
#include <openssl/opensslv.h>
1 error generated.
Failed to build and link a simple executable using OpenSSL

The file exists and it's located at:


How do I go about fixing this, thanks.


Well, after trying other solutions of this and other threads to no avail, I stumbled upon this one-liner that did the trick for me:

$ sudo OPENSSL_INCLUDE=/usr/local/opt/openssl/include OPENSSL_LIB=/usr/local/opt/openssl/lib PERL_MM_USE_DEFAULT=1 perl -MCPAN -e "install Crypt::SSLeay"

You might try the following:

$ perl Makefile.PL --incpath /usr/local/opt/openssl/include --libpath /usr/local/opt/openssl/lib

as per the Crypt-SSLeay install docs. (Note that the above assumes that the OpenSSL libraries, libcrypt and libssl, are installed in /usr/local/opt/openssl/lib on your Macbook.)

Hope this helps!


I typed this in:

cpanm LWP::Protocol::https

And then installed Crypt-SSLeay using:

cpanm Crypt::SSLeay

And it worked. When I tried to install Crypt::SSLEay before LWP::Protocol::https I got the same error as you originally did.

  • what macOS version are you using? how did you install 'cpanm' (manually, brew, conda?) – Andrea T. Mar 4 '20 at 18:17

You must log in to answer this question.