Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL error building/configuring library on Ubuntu 22.04 in WSL2 and building docs #2489

Closed
hamishwillee opened this issue Jan 3, 2025 · 10 comments · Fixed by #2491
Closed

Comments

@hamishwillee
Copy link
Collaborator

The build log for the docs is linked below. This is latest main as per today, set up as per the build instructions on Ubuntu 22.04. The environment was not completely clean, but the build was. Same error if I do the configure:

https://gist.github.com/hamishwillee/4b23a2ca97fb587a6e356bddb5ec63dd

Last few lines are:

[ 99%] Building CXX object src/integration_tests/CMakeFiles/integration_tests_runner.dir/mavlink_passthrough.cpp.o
[100%] Building CXX object src/integration_tests/CMakeFiles/integration_tests_runner.dir/mission_transfer_lossy.cpp.o
[100%] Linking CXX executable integration_tests_runner
/usr/bin/ld: ../mavsdk/libmavsdk.so.2.12.2: undefined reference to `SSL_get0_group_name'
collect2: error: ld returned 1 exit status
make[2]: *** [src/integration_tests/CMakeFiles/integration_tests_runner.dir/build.make:694: src/integration_tests/integration_tests_runner] Error 1
make[2]: Leaving directory '/home/ubuntu/github/mavsdk/MAVSDK/tools/docs'
make[1]: *** [CMakeFiles/Makefile2:918: src/integration_tests/CMakeFiles/integration_tests_runner.dir/all] Error 2
make[1]: Leaving directory '/home/ubuntu/github/mavsdk/MAVSDK/tools/docs'
make: *** [Makefile:136: all] Error 2
make: Leaving directory '/home/ubuntu/github/mavsdk/MAVSDK/tools/docs'
@JonasVautherin
Copy link
Collaborator

JonasVautherin commented Jan 3, 2025

So it builds and installs OpenSSL properly:

But then it finds the wrong one:

-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.4.0")

Finally it breaks with some undefined reference to SSL, which doesn't seem surprising given what happens before.

[100%] Linking CXX executable integration_tests_runner
/usr/bin/ld: ../mavsdk/libmavsdk.so.2.12.2: undefined reference to `SSL_get0_group_name'

So now the question is: why does it not find the correct OpenSSL in WSL2? 😇 It seems like it works in CI (Ubuntu 22.04), so somehow something is different in WSL2. If someone can debug it, I would personally approach it like this:

  • As per the logs, openssl is installed in /home/ubuntu/github/mavsdk/MAVSDK/tools/docs/third_party/install. The goal is to have this path appear instead of the other one in this line: -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.4.0").
  • The MAVSDK superbuild sets CMAKE_PREFIX_PATH to point to /home/ubuntu/github/mavsdk/MAVSDK/tools/docs/third_party/install, which we can see works for other dependencies, e.g. (from the log):
-- Found curl via config file: /home/ubuntu/github/mavsdk/MAVSDK/tools/docs/third_party/install/lib/cmake/CURL

From all those points, maybe the first question would be: which version of CMake are you running on your WSL2, and could you try an updated version? It should be possible to download the latest version from the CMake website and install it 👍.

@julianoes
Copy link
Collaborator

I think it doesn't find the correct OpenSSL in general. This is on my Ubuntu 24.04, with SUPERBUILD:

-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.13") 

@JonasVautherin
Copy link
Collaborator

Which version of CMake do you have with Ubuntu 24.04?

@julianoes
Copy link
Collaborator

cmake --version
cmake version 3.28.3

I don't think it's that. I think it's that we're not actually using find_package(OpenSSL REQUIRED) if we don't build the mavsdk_server.

Just testing that now, will make a PR soon.

@julianoes
Copy link
Collaborator

Hm, adding the manual find_package does not work on 22.04 with cmake 3.22.1. 🤔

@julianoes
Copy link
Collaborator

julianoes commented Jan 5, 2025

Maybe we should throw out openssl and use boringssl instead, although not sure what Curl will do in that case.

@julianoes
Copy link
Collaborator

julianoes commented Jan 5, 2025

Adding this for debugging in src/CMakeLists.txt:

set(OPENSSL_ROOT_DIR "${CMAKE_PREFIX_PATH}")
set(OPENSSL_INCLUDE_DIR "${CMAKE_PREFIX_PATH}/include")
set(OPENSSL_LIBRARY_DIR "${CMAKE_PREFIX_PATH}/lib64")

find_package(OpenSSL REQUIRED)

message(STATUS "OPENSSL_FOUND: ${OPENSSL_FOUND}")
message(STATUS "OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}")
message(STATUS "OPENSSL_CRYPTO_LIBRARIES: ${OPENSSL_CRYPTO_LIBRARIES}")
message(STATUS "OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}")
message(STATUS "OPENSSL_SSL_LIBRARIES: ${OPENSSL_SSL_LIBRARIES}")
message(STATUS "OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
message(STATUS "OPENSSL_VERSION: ${OPENSSL_VERSION}")
message(STATUS "OPENSSL_APPLINK_SOURCE: ${OPENSSL_APPLINK_SOURCE}")

Ubuntu 22.04 with cmake 3.22.1:

-- OPENSSL_FOUND: TRUE
-- OPENSSL_INCLUDE_DIR: /home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/include
-- OPENSSL_CRYPTO_LIBRARY: /usr/lib/x86_64-linux-gnu/libcrypto.so
-- OPENSSL_CRYPTO_LIBRARIES: /usr/lib/x86_64-linux-gnu/libcrypto.so
-- OPENSSL_SSL_LIBRARY: /usr/lib/x86_64-linux-gnu/libssl.so
-- OPENSSL_SSL_LIBRARIES: /usr/lib/x86_64-linux-gnu/libssl.so
-- OPENSSL_LIBRARIES: /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so
-- OPENSSL_VERSION: 3.4.0
-- OPENSSL_APPLINK_SOURCE:

Ubuntu 24.04 with cmake 3.28.3:

-- Found OpenSSL: /home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/lib64/libcrypto.a   
-- OPENSSL_FOUND: TRUE
-- OPENSSL_INCLUDE_DIR: /home/julianoes/src/upstream/MAVSDK/install-debug;/home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/include
-- OPENSSL_CRYPTO_LIBRARY: /home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/lib64/libcrypto.a
-- OPENSSL_CRYPTO_LIBRARIES: /home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/lib64/libcrypto.a
-- OPENSSL_SSL_LIBRARY: /home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/lib64/libssl.a
-- OPENSSL_SSL_LIBRARIES: /home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/lib64/libssl.a
-- OPENSSL_LIBRARIES: /home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/lib64/libssl.a;/home/julianoes/src/upstream/MAVSDK/build-debug/third_party/install/lib64/libcrypto.a
-- OPENSSL_VERSION: 
-- OPENSSL_APPLINK_SOURCE:

What a mess.

@julianoes
Copy link
Collaborator

I managed to copy over the FindOpenSSL.cmake file from 3.28.3 and add it to the modules carried by MAVSDK. This seems to work for find_package(OpenSSL REQUIRED) but does not get used within the cURL build. Not sure how to add it there.

@JonasVautherin
Copy link
Collaborator

JonasVautherin commented Jan 6, 2025

So CMake 3.28.3 finds it, but CMake 3.22.1 doesn't?

but does not get used within the cURL build. Not sure how to add it there.

Did you try adding it here?

@julianoes
Copy link
Collaborator

julianoes commented Jan 6, 2025

@JonasVautherin good idea. Let's see if this works: #2491

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants