Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
585 stars 739 forks source link

iothub_client_sample_mqtt_dm sample generates unsafe header/library path used in cross-compilation error #2543

Closed licensedslacker closed 9 months ago

licensedslacker commented 9 months ago

Development Machine, OS, Compiler (and Other Relevant Toolchain Info)

Ubuntu 22.04 on WSL2 Cross Compiled using GCC 12.3 (buildroot based cross compiler)

SDK Version (Please Give Commit SHA if Manually Compiling)

master 1.10.1 1.11.0

Protocol

MQTT

Describe the Bug

iothub_client_sample_mqtt_dm sample generates error while cross-compiling because of the include path "-I/usr/include/azureiot"

The actual error message is: "ERROR: unsafe header/library path used in cross-compilation: '-I/usr/include/azureiot'"

The path is set in the sample's CMakeLists.txt file:

set(AZUREIOT_INC_FOLDER "pi_device" "../../../serializer/inc" "." "/usr/include/azureiot" "/usr/include/azureiot/inc")
include_directories(${AZUREIOT_INC_FOLDER})

CMake project configured with the command cmake -S . -B corss_build -G Ninja --toolchain custom-toolchain.cmake -DCMAKE_BUILD_TYPE=Release -Duse_http=off -Dskip_samples=off

MCVE

Console Logs

licensedslacker commented 9 months ago

After giving a second thought for this, I think it's not very common use case to cross compile samples. Samples might be tested on the host system rather than in the target system. Using -Dskip_samples=on parameter for CMake might the desired way to get the libraries for the target system.