Torizon tool chain can't find openssl

Hi I used following toolchains

  1. “torizon/debian-cross-toolchain-arm64:3.3.0-bookworm” which is not finding openssl and giving following error
  2. torizon/debian-cross-toolchain-ssh-arm64

I installed openssl by following command
RUN apt-get -q -y update &&
apt-get -q -y install
build-essential
software-properties-common
openssl
libssl-dev:arm64
cmake

ERROR Message:

Make Error at /usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: SSL Crypto) (found version
“3.0.14”)
Call Stack (most recent call first):
/usr/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.25/Modules/FindOpenSSL.cmake:613 (find_package_handle_standard_args)
CMakeLists.txt:36 (find_package)

– Configuring incomplete, errors occurred!
See also “/home/torizon/app/build-arm64/CMakeFiles/CMakeOutput.log”.
See also “/home/torizon/app/build-arm64/CMakeFiles/CMakeError.log”.

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


It looks like you’re encountering an issue where CMake cannot find the OpenSSL library even though it is installed. This is a common issue when the library paths are not correctly set or recognized by CMake. Here are a few steps you can take to resolve this:

  1. Set the OPENSSL_ROOT_DIR Environment Variable:
    You can explicitly set the OPENSSL_ROOT_DIR environment variable to point to the directory where OpenSSL is installed. You can do this in your Dockerfile or in your build script.

    export OPENSSL_ROOT_DIR=/usr/lib/ssl
    
  2. Specify OpenSSL Directories in CMake:
    You can also specify the OpenSSL directories directly in your CMakeLists.txt file.

    set(OPENSSL_ROOT_DIR /usr/lib/ssl)
    set(OPENSSL_INCLUDE_DIR /usr/include/openssl)
    find_package(OpenSSL REQUIRED)
    
  3. Verify Installation Paths:
    Ensure that OpenSSL and its development libraries are correctly installed. You can check the installation paths:

    dpkg -L libssl-dev:arm64
    
  4. Update and Install Dependencies:
    Make sure all dependencies are up to date and correctly installed. You can update and install them using:

    RUN apt-get -q -y update && \
        apt-get -q -y install build-essential software-properties-common openssl libssl-dev:arm64 cmake
    
  5. Check CMake Version Compatibility:
    Ensure that the version of CMake you are using is compatible with the version of OpenSSL installed. Sometimes, newer versions of OpenSSL might not be fully supported by older versions of CMake.

If you follow these steps and still encounter issues, please provide more details about your environment and any additional error messages you receive. This will help in diagnosing the problem further.

Hi @khaled.hassan !

Could you please share the exact content of Dockerfile you are using?

The one you shared is incomplete and invalid:

RUN apt-get -q -y update &&
apt-get -q -y install
build-essential
software-properties-common
openssl
libssl-dev:arm64
cmake
...

For each line break you must use the \:

RUN apt-get -q -y update && \
apt-get -q -y install \
build-essential \
software-properties-common \
openssl \
libssl-dev:arm64 \
cmake
...

So, if you could share the complete and exact Dockerfile you are trying to use, we could also try building it on our side.

Best regards,

Hi, Please find the updated docker sdk and docker file file.
Dockerfile.sdk (1.0 KB)
Dockerfile (2.8 KB)

Hi @khaled.hassan !

Thanks for the info.

I managed to build a project using Torizon IDE Extension (current version v2.6.2) using the C++ CMake Console Application template.

The final binary seems not to be actually working, but it is able to compile and be executed on the module.

Please find attached the example project:
openssl-hello-world.tar (610 KB)

Some details to consider:

  • libssl added to torizonPackages.json
  • Instead of compiling C++, it is compiling C, so:
    • main.cpp became main.c
    • CMakeLists.txt now targets C language and not CXX (maybe I didn’t need to remove CXX from the LANGUAGES :thinking:)
    • Since I used torizonPackages.json to add my dependencies, I didn’t need to manually modify Dockerfile, Dockerfile.debug nor Dockerfile.sdk
  • I added the necessary libs [1] to CMakeLists.txt using target_link_libraries
  • I added "www.google.com" to the args of the Torizon ARMv8 task on the file launch.json, so the application executed on the module would have some hostname to work on.

The content of the main.c came from [2]. I just modified it to print to stdout instead of stderr.

Be aware that I have no idea how main.c works! I just copied it from the referred repository :sweat_smile:. I have never developed anything using OpenSSL.

But I hope that this project helps you, since it is building successfully and the resulting binary is successfully executing on the module (and on the computer as well, when compiled for AMD64).

[1] FindOpenSSL — CMake 3.30.3 Documentation
[2] openssl-examples/openssl-examples/tls-connect.c at 12881684b72fc9197630efd75f7ff7260062a741 · theno/openssl-examples · GitHub

Best regards,