Could NOT find OpenSSL error while compiling cmake from source

Written by - 1 comments

Published on - Listed in Linux


While compiling the (currently) newest cmake 3.23.2 on an Ubuntu 20.04 system, the following error was shown during the configure part:

ck@build:~/cmake-3.23.2 $ ./configure
---------------------------------------------
CMake 3.23.2, Copyright 2000-2022 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc   
C++ compiler on this system is: g++    
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
[...]
-- Looking for gethostbyname in c - found
-- Looking for recv in network;dl
-- Looking for recv in network;dl - not found
-- Looking for gethostname
-- Looking for gethostname - found
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
CMake Error at Utilities/cmcurl/CMakeLists.txt:586 (message):
  Could not find OpenSSL.  Install an OpenSSL development package or
  configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.

Obviously the error mentions OpenSSL. In this case you need to make sure to install the OpenSSL header and development files as well (not just openssl itself):

ck@build:~/cmake-3.23.2 $ dpkg -l|grep ssl
ii  libssl1.0.0:amd64         1.0.2n-1ubuntu5.4     amd64  Secure Sockets Layer toolkit - shared libraries
ii  libssl1.1:amd64           1.1.1f-1ubuntu2.13    amd64  Secure Sockets Layer toolkit - shared libraries
ii  libxmlsec1-openssl:amd64  1.2.28-2              amd64  Openssl engine for the XML security library
ii  libzstd1:amd64            1.4.4+dfsg-3ubuntu0.1 amd64  fast lossless compression algorithm
ii  openssl                   1.1.1f-1ubuntu2.13    amd64  Secure Sockets Layer toolkit - cryptographic utility
ii  python3-openssl           19.0.0-1build1        all    Python 3 wrapper around the OpenSSL library

The package in question is libssl-dev (in Debian and Ubuntu anyway), which is not shown in dpkg yet. Install the missing package:

root@build:~# apt-get install libssl-dev

And then run ./configure in cmake's source folder again:

ck@build:~/cmake-3.23.2 $ ./configure
---------------------------------------------
CMake 3.23.2, Copyright 2000-2022 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc   
C++ compiler on this system is: g++    
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
[...]
-- Checking support for ARCHIVE_CRYPTO_SHA512_OPENSSL -- found
-- Checking for curses support
-- Checking for curses support - Failed
-- Looking for a Fortran compiler
-- Looking for a Fortran compiler - NOTFOUND
-- Performing Test run_pic_test
-- Performing Test run_pic_test - Success
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /root/cmake-3.23.2
---------------------------------------------
CMake has bootstrapped.  Now run make.

The cmake compile can now be finished using make and make install.


Add a comment

Show form to leave a comment

Comments (newest first)

Oleg from wrote on Jul 3rd, 2022:

Thank you so much!
You helped me to deal with the problem.