0
root@760501de936d:/home/project/build# ldconfig -p | grep ssl
        libssl.so.1.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libssl.so.1.1
        libssl.so.1.0.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0
        libssl.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libssl.so

My project is trying to link with OpenSSL. How can I force it to use libssl.so.1.1?

I'm using cmake

find_library(LIB_SSL ssl)

then

target_link_libraries(h264_decoder_cli PRIVATE 
${LIB_SSL} ${LIB_CRYPTO} ...)

however I get things like

tls_openssl.c:(.text+0x3a8): undefined reference to `OPENSSL_init_ssl'

I don't know why but only the version 1.1 has this symbol

root@760501de936d:/home/project/build# nm -D /usr/lib/x86_64-linux-gnu/libssl.so | grep OPENSSL_init_ssl
root@760501de936d:/home/project/build# nm -D /usr/lib/x86_64-linux-gnu/libssl.so.1.1 | grep OPENSSL_init_ssl
0000000000033ff0 T OPENSSL_init_ssl

I checked how cmake is compiling and it's simply putting -lssl -lcrypto

Guerlando OCs
  • 1,886
  • 9
  • 61
  • 150
  • @xhienne `libssl.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libssl.so` what this means? And if it were, then their `nm` outputs woudl be the same – Guerlando OCs Jul 25 '20 at 23:43
  • Check the question on how to [link against a specific version of a shared library](https://stackoverflow.com/questions/828053/how-do-you-link-to-a-specific-version-of-a-shared-library-in-gcc) – Pak Uula Jul 26 '20 at 03:37
  • @PakUula I tried forcing this behaviour with `find_library(LIB_SSL ssl NAMES libssl.so.1.1 PATHS /usr/lib/x86_64-linux-gnu/)` but I see on the output that it does only `-lssl` – Guerlando OCs Jul 26 '20 at 04:55

1 Answers1

0

To find OpenSSL CMake has a finder module, so you don't need to use anything else (i.e., find_library). Use find_package(OpenSSL 1.1 ...) to require particular version.

zaufi
  • 6,811
  • 26
  • 34