aws-iot-device-sdk-embedded-C icon indicating copy to clipboard operation
aws-iot-device-sdk-embedded-C copied to clipboard

Linking issue while running "http_demo_s3_download" after cross compilation.

Open dnkabhay01 opened this issue 1 year ago • 1 comments

For the past few days, I'm trying to cross-compile aws-iot-device-sdk-embedded-C SDK's http_demo_s3_download example for my target Linux system but getting linking error and the same demo I was able to run on my HOST PC by following steps.

HOST System : Architecture -> x86_64 , kernel -> 5.4.0-109-generic TARGET System : Architecture -> armv7l , kernel -> 4.19.78-linux4sam-6.2

I have downloaded the aws-iot-device-sdk-embedded-C in my Host system and trying to cross-compile for my target system using the following command:

cmake -DCMAKE_C_COMPILER=/home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/bin/arm-linux-gnueabihf-gcc -DOPENSSL_INCLUDE_DIR=/home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/usr/include -DOPENSSL_CRYPTO_LIBRARY=/home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypt.so -DOPENSSL_ROOT_DIR=/home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/usr/include/openssl -DOPENSSL_SSL_LIBRARY=/home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/usr/lib/libssl.so -DPKG_CONFIG_EXECUTABLE=/home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/usr/bin/pkg-config -S ..

Below is the log after cross-compilation:

`-- The C compiler identification is GNU 7.3.1 -- The CXX compiler identification is GNU 7.3.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/bin/arm-linux-gnueabihf-gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/bin/arm-linux-gnueabihf-c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE
-- Found Git: /usr/bin/git (found version "2.25.1") Skipping submodule '../../../libraries/aws/device-defender-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/device-defender-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/device-defender-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/device-shadow-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/device-shadow-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/device-shadow-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/fleet-provisioning-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/fleet-provisioning-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/fleet-provisioning-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/jobs-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/jobs-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/jobs-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/ota-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/ota-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/ota-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/ota-for-aws-iot-embedded-sdk/source/dependency/coreJSON/' Skipping submodule '../../../libraries/aws/ota-for-aws-iot-embedded-sdk/source/dependency/coreJSON/' Skipping submodule '../../../libraries/aws/ota-for-aws-iot-embedded-sdk/source/dependency/coreJSON/' Skipping submodule '../../../libraries/aws/sigv4-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/sigv4-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/aws/sigv4-for-aws-iot-embedded-sdk/' Skipping submodule '../../../libraries/standard/backoffAlgorithm/' Skipping submodule '../../../libraries/standard/coreHTTP/' Skipping submodule '../../../libraries/standard/coreHTTP/' Skipping submodule '../../../libraries/standard/coreHTTP/' Skipping submodule '../../../libraries/standard/coreJSON/' Skipping submodule '../../../libraries/standard/coreJSON/' Skipping submodule '../../../libraries/standard/coreJSON/' Skipping submodule '../../../libraries/standard/coreMQTT/' Skipping submodule '../../../libraries/standard/coreMQTT/' Skipping submodule '../../../libraries/standard/coreMQTT/' Skipping submodule '../../../../libraries/standard/corePKCS11/' Skipping submodule '../../../libraries/standard/corePKCS11/' Skipping submodule '../../../libraries/standard/corePKCS11/' Skipping submodule '../../../libraries/standard/corePKCS11/' -- Found OpenSSL: /home/dnk074/Desktop/abhay_sama5d3/i2c_image/buildroot-at91/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libcrypt.so (found version "1.1.1g")
Using values in demo_config.h to define the following macros for defender_demo: ROOT_CA_CERT_PATH THING_NAME CLIENT_IDENTIFIER OS_NAME OS_VERSION HARDWARE_PLATFORM_NAME Found the following definitions for defender_demo: ROOT_CA_CERT_PATH, THING_NAME, CLIENT_IDENTIFIER, OS_NAME, OS_VERSION, HARDWARE_PLATFORM_NAME WARNING: defender_demo missing definitions for macros: AWS_IOT_ENDPOINT, CLIENT_CERT_PATH, CLIENT_PRIVATE_KEY_PATH To run defender_demo, define required macros in defender_demo/demo_config.h.

Using values in demo_config.h to define the following macros for fleet_provisioning_with_csr_demo: ROOT_CA_CERT_PATH CSR_SUBJECT_NAME CLIENT_IDENTIFIER OS_NAME OS_VERSION HARDWARE_PLATFORM_NAME Found the following definitions for fleet_provisioning_with_csr_demo: ROOT_CA_CERT_PATH, CSR_SUBJECT_NAME, CLIENT_IDENTIFIER, OS_NAME, OS_VERSION, HARDWARE_PLATFORM_NAME WARNING: fleet_provisioning_with_csr_demo missing definitions for macros: AWS_IOT_ENDPOINT, CLAIM_CERT_PATH, CLAIM_PRIVATE_KEY_PATH, PROVISIONING_TEMPLATE_NAME, DEVICE_SERIAL_NUMBER To run fleet_provisioning_with_csr_demo, define required macros in fleet_provisioning_with_csr_demo/demo_config.h.

Using values in demo_config.h to define the following macros for http_demo_basic_tls: SERVER_HOST HTTPS_PORT ROOT_CA_CERT_PATH Found the following definitions for http_demo_basic_tls: SERVER_HOST, HTTPS_PORT, ROOT_CA_CERT_PATH All required definitions for http_demo_basic_tls were found - Adding to default target.

Using values in demo_config.h to define the following macros for http_demo_mutual_auth: AWS_HTTPS_PORT ROOT_CA_CERT_PATH Found the following definitions for http_demo_mutual_auth: AWS_HTTPS_PORT, ROOT_CA_CERT_PATH All required definitions for http_demo_mutual_auth were found - Adding to default target.

Using values in demo_config.h to define the following macros for http_demo_mutual_auth: ROOT_CA_CERT_PATH Found the following definitions for http_demo_mutual_auth: ROOT_CA_CERT_PATH WARNING: http_demo_mutual_auth missing definitions for macros: AWS_IOT_ENDPOINT, CLIENT_CERT_PATH, CLIENT_PRIVATE_KEY_PATH To run http_demo_mutual_auth, define required macros in http_demo_mutual_auth/demo_config.h.

Using values in demo_config.h to define the following macros for http_demo_plaintext: SERVER_HOST HTTP_PORT Found the following definitions for http_demo_plaintext: SERVER_HOST, HTTP_PORT All required definitions for http_demo_plaintext were found - Adding to default target.

Using values in demo_config.h to define the following macros for http_demo_s3_download: HTTPS_PORT ROOT_CA_CERT_PATH CLIENT_CERT_PATH CLIENT_PRIVATE_KEY_PATH AWS_IOT_THING_NAME AWS_IOT_CREDENTIAL_PROVIDER_ENDPOINT AWS_IOT_CREDENTIAL_PROVIDER_ROLE AWS_S3_BUCKET_NAME AWS_S3_BUCKET_REGION AWS_S3_OBJECT_NAME Found the following definitions for http_demo_s3_download: HTTPS_PORT, ROOT_CA_CERT_PATH, CLIENT_CERT_PATH, CLIENT_PRIVATE_KEY_PATH, AWS_IOT_THING_NAME, AWS_IOT_CREDENTIAL_PROVIDER_ENDPOINT, AWS_IOT_CREDENTIAL_PROVIDER_ROLE, AWS_S3_BUCKET_NAME, AWS_S3_BUCKET_REGION, AWS_S3_OBJECT_NAME WARNING: http_demo_s3_download missing definitions for macros: ROOT_CA_CERT_PATH_S3 To run http_demo_s3_download, define required macros in http_demo_s3_download/demo_config.h.

Using values in demo_config.h to define the following macros for http_demo_s3_download_multithreaded: HTTPS_PORT ROOT_CA_CERT_PATH Found the following definitions for http_demo_s3_download_multithreaded: HTTPS_PORT, ROOT_CA_CERT_PATH WARNING: http_demo_s3_download_multithreaded missing definitions for macros: S3_PRESIGNED_GET_URL To run http_demo_s3_download_multithreaded, define required macros in http_demo_s3_download_multithreaded/demo_config.h.

Using values in demo_config.h to define the following macros for http_demo_s3_upload: HTTPS_PORT ROOT_CA_CERT_PATH Found the following definitions for http_demo_s3_upload: HTTPS_PORT, ROOT_CA_CERT_PATH WARNING: http_demo_s3_upload missing definitions for macros: S3_PRESIGNED_PUT_URL, S3_PRESIGNED_GET_URL To run http_demo_s3_upload, define required macros in http_demo_s3_upload/demo_config.h.

Mosquitto was not installed. It will be built from source to run jobs_demo_mosquitto. CMake Deprecation Warning at demos/jobs/jobs_demo_mosquitto/libmosquitto/CMakeLists.txt:11 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.

Update the VERSION argument value or use a ... suffix to tell CMake that the project does not need compatibility with older versions.

-- WITH_DLT = OFF -- Looking for getaddrinfo_a in anl -- Looking for getaddrinfo_a in anl - found All required definitions for jobs_demo_mosquitto were found - Adding to default target.

Using values in demo_config.h to define the following macros for mqtt_demo_basic_tls: CLIENT_IDENTIFIER BROKER_PORT Found the following definitions for mqtt_demo_basic_tls: CLIENT_IDENTIFIER, BROKER_PORT WARNING: mqtt_demo_basic_tls missing definitions for macros: ROOT_CA_CERT_PATH, BROKER_ENDPOINT To run mqtt_demo_basic_tls, define required macros in mqtt_demo_basic_tls/demo_config.h.

Using values in demo_config.h to define the following macros for mqtt_demo_mutual_auth: ROOT_CA_CERT_PATH CLIENT_IDENTIFIER Found the following definitions for mqtt_demo_mutual_auth: ROOT_CA_CERT_PATH, CLIENT_IDENTIFIER WARNING: mqtt_demo_mutual_auth missing definitions for macros: AWS_IOT_ENDPOINT, CLIENT_CERT_PATH, CLIENT_PRIVATE_KEY_PATH To run mqtt_demo_mutual_auth, define required macros in mqtt_demo_mutual_auth/demo_config.h.

Using values in demo_config.h to define the following macros for mqtt_demo_plaintext: BROKER_PORT CLIENT_IDENTIFIER Found the following definitions for mqtt_demo_plaintext: BROKER_PORT, CLIENT_IDENTIFIER WARNING: mqtt_demo_plaintext missing definitions for macros: BROKER_ENDPOINT To run mqtt_demo_plaintext, define required macros in mqtt_demo_plaintext/demo_config.h.

Using values in demo_config.h to define the following macros for mqtt_demo_serializer: BROKER_PORT CLIENT_IDENTIFIER Found the following definitions for mqtt_demo_serializer: BROKER_PORT, CLIENT_IDENTIFIER WARNING: mqtt_demo_serializer missing definitions for macros: BROKER_ENDPOINT To run mqtt_demo_serializer, define required macros in mqtt_demo_serializer/demo_config.h.

Using values in demo_config.h to define the following macros for mqtt_demo_subscription_manager: BROKER_PORT CLIENT_IDENTIFIER Found the following definitions for mqtt_demo_subscription_manager: BROKER_PORT, CLIENT_IDENTIFIER WARNING: mqtt_demo_subscription_manager missing definitions for macros: ROOT_CA_CERT_PATH, BROKER_ENDPOINT To run mqtt_demo_subscription_manager, define required macros in mqtt_demo_subscription_manager/demo_config.h.

Using values in demo_config.h to define the following macros for ota_demo_core_http: ROOT_CA_CERT_PATH ROOT_CA_CERT_PATH_HTTP CLIENT_IDENTIFIER Found the following definitions for ota_demo_core_http: ROOT_CA_CERT_PATH, ROOT_CA_CERT_PATH_HTTP, CLIENT_IDENTIFIER WARNING: ota_demo_core_http missing definitions for macros: AWS_IOT_ENDPOINT, CLIENT_CERT_PATH, CLIENT_PRIVATE_KEY_PATH To run ota_demo_core_http, define required macros in ota_demo_core_http/demo_config.h.

Using values in demo_config.h to define the following macros for ota_demo_core_mqtt: ROOT_CA_CERT_PATH CLIENT_IDENTIFIER Found the following definitions for ota_demo_core_mqtt: ROOT_CA_CERT_PATH, CLIENT_IDENTIFIER WARNING: ota_demo_core_mqtt missing definitions for macros: AWS_IOT_ENDPOINT, CLIENT_CERT_PATH, CLIENT_PRIVATE_KEY_PATH To run ota_demo_core_mqtt, define required macros in ota_demo_core_mqtt/demo_config.h.

Using values in demo_config.h to define the following macros for shadow_demo_main: ROOT_CA_CERT_PATH CLIENT_IDENTIFIER THING_NAME OS_NAME OS_VERSION HARDWARE_PLATFORM_NAME Found the following definitions for shadow_demo_main: ROOT_CA_CERT_PATH, CLIENT_IDENTIFIER, THING_NAME, OS_NAME, OS_VERSION, HARDWARE_PLATFORM_NAME WARNING: shadow_demo_main missing definitions for macros: AWS_IOT_ENDPOINT, CLIENT_CERT_PATH, CLIENT_PRIVATE_KEY_PATH To run shadow_demo_main, define required macros in shadow_demo_main/demo_config.h.

-- Looking for fork -- Looking for fork - found Downloading the Amazon Root CA certificate... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1188 100 1188 0 0 18276 0 --:--:-- --:--:-- --:--:-- 18276 -- Configuring done -- Generating done -- Build files have been written to: /home/dnk074/Desktop/TEST_MQTT_BROKER/aws-iot-device-sdk-embedded-c/build``

Now when I am trying to build and run a demo "http_demo_s3_download", by make http_demo_s3_download. I am facing the linking issue for openssl.

Log after that :

Screenshot_2022-09-28_14-53-31

I tried to follow this link but it didn't help me. 1585

dnkabhay01 avatar Sep 28 '22 09:09 dnkabhay01

I'm a bit of a novice when it comes to cross compilation, but it would seem to me that you need to install the openssl library of your target. You're openssl instillations may not (looks to be more like will not) be the same between your host and target.

Some questions I have:

  • What CMake file are you building against? Is it this one?
  • Have you tried building with fewer CMake flags? Browsing online it seems like many people only set the root dir and include dir. This is mostly my curiousity. Nothing is standing out as wrong.

kstribrnAmzn avatar Oct 04 '22 16:10 kstribrnAmzn