How To Install OpenSSL Libraries On Ubuntu, Debian, Mint?

OpenSSL libraries are required to build OpenSSL-based applications. While trying to build by using gcc with openssl library and function the -lssl option is used. But you may get an error like “foo.cpp:21:25: error: openssl/bio.h: No such file or directory” which means the openssl library can not be found or not installed. In this tutorial, we will learn how to install OpenSSL libraries to build applications in Ubuntu, Debian, Mint.

OpenSSL Headers and Build Errors

OpenSSL provides a lot of features for security. All of them are categorized under diffrent C header files. Below we list some of the most popular OpenSSL library headers. If you need one of them the OpenSSL library should be installed for the current operating system.

#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/des.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>

If the OpenSSL development library is not installed when you try to build the C application with OpenSSL library dependency you will get the following errors. The build operation with the OpenSSL library can be start with the following gcc command.

gcc -lssl sample.cpp
sample.cpp:21:25: error: openssl/bio.h: No such file or directory
sample.cpp:22:28: error: openssl/buffer.h: No such file or directory
sample.cpp:23:25: error: openssl/des.h: No such file or directory
sample.cpp:24:25: error: openssl/evp.h: No such file or directory
sample.cpp:25:25: error: openssl/pem.h: No such file or directory
sample.cpp:26:25: error: openssl/rsa.h: No such file or directory

Install OpenSSL Development Libraries and Packages

The OpenSSL Development Libraries and Packages are provided with the name “libssl-dev”. The “libssl-dev” is the package name for the Ubuntu, Debian, Mint, and related apt-based distributions. Before installing the OpenSSL development libraries and package we can display information about it.

apt show libssl-dev
Package: libssl-dev
 Version: 1.1.1f-1ubuntu4.3
 Priority: optional
 Section: libdevel
 Source: openssl
 Origin: Ubuntu
 Maintainer: Ubuntu Developers [email protected]
 Original-Maintainer: Debian OpenSSL Team [email protected]
 Installed-Size: 8.050 kB
 Depends: libssl1.1 (= 1.1.1f-1ubuntu4.3)
 Suggests: libssl-doc
 Conflicts: libssl1.0-dev
 Download-Size: 1.586 kB
 APT-Manual-Installed: yes
 APT-Sources: groovy-updates/main amd64 Packages
 Description: Secure Sockets Layer toolkit - development files
  This package is part of the OpenSSL project's implementation of the SSL
  and TLS cryptographic protocols for secure communication over the
  It contains development libraries, header files, and manpages for libssl
  and libcrypto.
 N: There is 1 additional record. Please use the '-a' switch to see it

By using the following command the OpenSSL Development Libraries and package can be installed.

sudo apt install libssl-dev
Install OpenSSL Development Libraries and Package

The package name “libssl” is the name of the package and the “dev” is used specify that this package is a development library.

If you are using apt-get command instead of the apt in order to manage packages you can use the following command to install OpenSSQL development libraries and package.

sudo apt-get install libssl-dev

Install OpenSSL Development Libraries From Source

Alternatively the OpenSSL Development libraries can be installed from the source code. First the source code should be compiled into the binary and then installed properly. The adventage of the using source code is we can select whatever version we want. There is no dependency to the specific version provided by the Linux distribution. Disadventage of installing OpenSSL develpoment libraries from source is it is not easy as installing with package manager. There are multiple steps for this.

Download the OpenSSL source code from the You can select whatever version you want. In this example we download openssl-1.0.1.


Extract the compressed openssl source code with the tar command.

tar -xvzf openssl-1.0.1g.tar.gz

Navigate too the extracted openssl directory.

cd openssl-1.0.1g

Configure the openssl source code for compile operation.

 ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl

Compile the openssl and development libraries with the make command.


Install the compiled openssl binaries and development libraries with the “make install” command.

make install

Navigate to the OpenSSL installation directory and execute openssl command in order to check its version.

/usr/local/openssl/bin/openssl version

The output is like below.

OpenSSL 1.0.1g 7 Apr 2015

Leave a Comment