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,

Hi @khaled.hassan !

Do you have any update here?

Were you able to build it?

Please let us know :slight_smile:

Best regards,

@henrique.tx ,
Sorry I lost track of this issue. It was not fixed.
Can you try to build Paho library in tool-chain?

Hi @khaled.hassan !

Yes, I can. But I would like to first understand what you have tried.

Could you please share how you tried to build it on your side?

  • Which template did you use?
  • Which modifications you did to which template files?
  • Have you ever tried to build it native on your own computer (no cross-compilation embedded system involved)?
    • This is a very important step that will allow you to get acquainted to the process of building that specific repository and understand its process, so you can replicate it.

Best regards,

Hi Henrick,

Please find what I did.

  1. I can build paho library in Native Ubuntu and Torizon OS (Manually after going inside a docker container)
  2. My objective is to use Paho library (C/C++ later Python) from each of our docker container

I tried below things

  1. I am using “C++ CMake Console Application” as template
  2. Initially I built Paho in Torizon. I want to use the artifacts (.so and include) files from that artifacts to use from Open-Ocpp project. (Open-Ocpp is building properly in torizon)
    Please let me know if you have any more questions?
  3. I did modification in Dockerfile.sdk
    Dockerfile.sdk (1.2 KB)

On top of that would you please check below is the proper way to add LD_LIBRARY_PATH to toolchain?
docker-compose.yml (674 Bytes)

torizon-build:
environment:
- LD_LIBRARY_PATH=“${LD_LIBRARY_PATH}:/home/torizon/app:/usr/local/lib:/usr/local/include:/usr/local/share”

Hi @henrique.tx adding below in torizonPackages.json temporarily helped to to use the paho libraries

{
“prodRuntimeDeps”: [“libpaho-mqtt1.3”],
“devRuntimeDeps”: [“build-essential”,“libpaho-mqtt1.3”, “libpaho-mqttpp3-1”, “gcc”, “make”, “cmake”, “libssl3”, “libssl-dev”, “doxygen”, “graphviz”, “iproute2”, “git”],
“buildDeps”: [“libssl-dev”, “libpaho-mqtt-dev”, “libpaho-mqttpp-dev”]
}

Then I had to link it from executable like below from CMakeList.txt

target_link_libraries(quick_start_chargepoint

libpaho-mqtt3a.so
libpaho-mqtt3a.so.1
libpaho-mqtt3a.so.1.3.13
libpaho-mqtt3as.so
libpaho-mqtt3as.so.1
libpaho-mqtt3as.so.1.3.13
libpaho-mqtt3c.so
libpaho-mqtt3c.so.1
libpaho-mqtt3c.so.1.3.13
libpaho-mqtt3cs.so
libpaho-mqtt3cs.so.1
libpaho-mqtt3cs.so.1.3.13

libpaho-mqttpp3.so
libpaho-mqttpp3.so.1
libpaho-mqttpp3.so.1.4.0

)

However, it will be still good to know how to do the whole thing manually.

Best Regards
Md Khaled Ibn Hassan