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

Cross-compile application with openssl 1.0.2 fails in openssl 1.1.1 environment #1341

Closed
dilin-MS opened this issue Nov 21, 2019 · 5 comments
Assignees
Labels

Comments

@dilin-MS
Copy link

dilin-MS commented Nov 21, 2019

Hi, I would like to cross-compile my application with azure-iot-sdk-c on a docker container on my host machine, and run the executable binary file on my 32 bits Raspberry Pi, which is running the official Raspbian 32bits.

  1. I installed armv7 cross-compilation toolchain in my docker container
  2. Install the needded libs:
  • openssl: 1.0.2o
  • curl: 7.60.0
  • util: 2.32-rc2
  1. Install azure-iot-sdk-c using vcpkg.
./vcpkg install azure-iot-sdk-c[public-preview,use_prov_client]:arm-linux-custom

This is my customized arm-linux-custom.cmake file placed under vcpkg/triplets/ directory.

set(VCPKG_TARGET_ARCHITECTURE arm)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /work/vcpkg/scripts/toolchains/Toolchain.cmake)

The application can be successfully compiled.

On Raspbian openssl is 1.1.1, run the binary directly will cause error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory.
So I run the below commands before run the application.

 sudo ln -s /usr/lib/arm-linux-gnueabihf/libssl.so.1.1 /usr/lib/libssl.so.1.0.0
 sudo ln -s /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.0.0

But execution still fails, showing

symbol lookup error: ./app: undefined symbol: SSL_load_error_strings

Currenly I will have to install openssl 1.0.2 on my Raspbian (apt-get install libssl1.0 libssl1.0-dev) and use ln -s to point libssl.so.1.0.0 and libcrypto.so.1.0.0 to 1.0.2.

How to make the application able to run in a openssl 1.1.1 environment? Thanks in advance.

@dilin-MS dilin-MS changed the title Cross-compile appplication with openssl 1.0.2 cause "Segmentation fault" in openssl 1.1.1 environment Cross-compile appplication with openssl 1.0.2 fails in openssl 1.1.1 environment Nov 21, 2019
@dilin-MS dilin-MS changed the title Cross-compile appplication with openssl 1.0.2 fails in openssl 1.1.1 environment Cross-compile application with openssl 1.0.2 fails in openssl 1.1.1 environment Nov 21, 2019
@ewertons ewertons self-assigned this Nov 26, 2019
@ewertons
Copy link
Contributor

Hi @dilin-MS ,
compiling your application for one version of openssl and trying to run it using another might not be supported by OpenSSL (to confirm please check with OpenSSL).

To address your issue you might need to compile your application with the same version of openssl you intend to run it with. Try updating the openssl you used to compile your application.

@dilin-MS
Copy link
Author

dilin-MS commented Nov 27, 2019

Hi, I tried to pre-install openssl 1.1.1 and then installed azure-iot-sdk-c using vcpkg. I found that when install azure-iot-sdk-c via command ./vcpkg install azure-iot-sdk-c[public-preview,use_prov_client]:arm-linux-custom, it will install openssl 1.0.2 in its build system. And when I compile my application with azure-iot-sdk-c by adding the following lines in my application's CMakeLists.txt, the compilation can be done successfully but the generated binary file fails to execute, showing "Segmentation fault". Further gdb debug shows that some links towards azure-related libraries is wrong so the binary cannot find the correct libraries.

# Find azure_iot_sdks Vcpkg package
find_package(azure_iot_sdks REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_library(CURL NAMES curl-d curl)

target_link_libraries(my-executable-name
parson
iothub_client_mqtt_transport
iothub_client
digitaltwin_client
prov_auth_client
aziotsharedutil
umqtt
uuid
${CURL}
pthread
ssl
crypto
m
ZLIB::ZLIB
)

But the same applcation can be compiled successfully and worked well with openssl 1.1.1 if compiled with azure-iot-sdk-c from source code instead of vcpkg. I suspect the "segmentation fault" is because vcpkg install openssl 1.0.2 regardless of openssl 1.1.1 in the environment and the compilation fails to link the right target links.

How to compile applcation with azure-iot-sdk-c with openssl 1.1.1 while azure-iot-sdk-c is installed via vcpkg???

@ewertons
Copy link
Contributor

ewertons commented Nov 27, 2019

@dilin-MS ,
upon verifying the port files in the vcpkg repo, we observed that the openssl port is hardcoded to version 1.0.2s.
The openssl port does not seem to expose any option to override the version.

So answering your question you cannot directly build a solution using a custom version of openssl using vcpkg.

You will need to either build the code from source how you have done as you described above, or verify with OpenSSL about their plans to update their vcpkg port.
Searching on the web we did find that they do have an issue open requesting for vcpkg to be updated, but it is currently still open.

@ewertons
Copy link
Contributor

ewertons commented Dec 2, 2019

@dilin-MS ,
we will close this issue as the reply seems to explain well the situation, but please feel free to reopen the issue if you would like to follow up.

Thanks,
Azure IoT SDKs

@ewertons ewertons closed this as completed Dec 2, 2019
@az-iot-builder-01
Copy link
Collaborator

@ewertons, @dilin-MS, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

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

No branches or pull requests

3 participants