Bug #109251 Cannot compile 5.7.39 on Ubuntu 22.04 because ssl is not found
Submitted: 30 Nov 2022 16:06 Modified: 18 Jan 23:58
Reporter: Mark Callaghan Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.7.39, 5.7.40 OS:Ubuntu
Assigned to: CPU Architecture:x86

[30 Nov 2022 16:06] Mark Callaghan
I can compile MySQL 8.0.31 on the same host and that finds cmake. But 5.6.51, 5.7.39 and some 8.0 releases prior to 8.0.31 all fail because they can't find ssl. My blog post on this is here:

I know that 5.6 is end of life, but I think that 5.7 is still active.

How to repeat:

Download source, run cmake:
cmake \
      -DBUILD_CONFIG=mysql_release \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DWITH_SSL="system" \
      -DWITH_ZLIB="system" \
      -DMYSQL_DATADIR="${prefix}/data" \
      -DMYSQL_UNIX_ADDR="${prefix}/var/mysql.sock" \
      -DWITH_BOOST=$PWD/../boost \
      -DWITH_NUMA=ON \

The error text from cmake is:
CMake Error at cmake/ssl.cmake:63 (MESSAGE):
  Please install the appropriate openssl developer package.

Call Stack (most recent call first):
  cmake/ssl.cmake:306 (FATAL_SSL_NOT_FOUND_ERROR)
  CMakeLists.txt:603 (MYSQL_CHECK_SSL)

SSL is there, and was found by 8.0.31:
$ find /usr -name \*ssl\*\.a -print

mdcallag@amd2:~/b/mysql-5.7.39/build$ find /usr -name \*ssl\*\.so -print

$ find /usr -name \*ssl\*\.h -print

And cmake stdout that references SSL shows that the version numbers were not parsed:
-- OPENSSL_INCLUDE_DIR = /usr/include
-- OPENSSL_LIBRARY = /usr/lib/x86_64-linux-gnu/libssl.so
Cannot find appropriate system libraries for WITH_SSL=system.
Make sure you have specified a supported SSL version.
system (use the OS openssl library),

Suggested fix:
The root cause is that cmake/ssl.cmake is unable to parse the version number from openssl/openslv.h. My hack to fix this (because I don't know cmake) was to copy/paste the parsing code from the 8.0.31 version of cmake/ssl.cmake.

Perhaps there is another way. Regardless, I hope this error message is made less ambiguous. It would be great for it to indicate which of the 4 problems triggered it (libraries not found, header not found, version number not parsed or wrong).
[1 Dec 2022 10:09] MySQL Verification Team
Hello Mark,

Thank you for the report and feedback.

[1 Dec 2022 10:15] MySQL Verification Team
5.7.40 build details

Attachment: 109251_5.7.40.results (application/octet-stream, text), 19.85 KiB.

[7 Jan 7:29] Roel Van de Paar
Thank you Mark for creating this bug.

I am running into this also. While 5.5 and 8.0 compile fine on Ubuntu 22.04, 5.6 and 5.7 fail with this issue.

This bug should be fixed asap IMHO, as it basically renders 5.6 and 5.7 unable to compile on the latest Ubuntu.

The following hack also makes 5.7 compile:

1. Open cmake/ssl.cmake
2. Search for "# If we are invoked with" (around line 239 in current code) and just before that line add the following:

    SET(OPENSSL_INCLUDE_DIR "/usr/include/openssl")
    SET(OPENSSL_LIBRARY "/lib/x86_64-linux-gnu/libssl.a")
    SET(CRYPTO_LIBRARY "/lib/x86_64-linux-gnu/libcrypto.a")

3. Compile as normal
[7 Jan 7:42] Roel Van de Paar
The same patch works for 5.6. However, the build will fail with other errors using standard cmake. The issue seems to be a change in C++ standards or similar. Using clang instead of cmake makes the build succeed.
[7 Jan 7:54] Roel Van de Paar
Btw, for 5.6 also search for 'If we are invoked with' and insert the same hack before that line, however that line has a lower line number (around line 205 currently) in 5.6.
[18 Jan 23:58] Mark Callaghan
Replying to a previous comment ...

Whether or not 8.x compiles OK on Ubuntu 22.04 depends on which version of 8.0. AFAIK MySQL 8 became ready for OpenSSL 3 in 8.0.30, so while I can get cmake to work for 8.0.28 with some edits, the build still fails.